[wp-trac] [WordPress Trac] #60682: Enhanced Dynamic Date and Time Formatting for DST Transition Notifications

WordPress Trac noreply at wordpress.org
Mon Mar 4 09:09:10 UTC 2024


#60682: Enhanced Dynamic Date and Time Formatting for DST Transition Notifications
-----------------------------------------------+---------------------------
 Reporter:  reklwera                           |      Owner:  (none)
     Type:  enhancement                        |     Status:  new
 Priority:  normal                             |  Milestone:  Awaiting
                                               |  Review
Component:  Options, Meta APIs                 |    Version:  trunk
 Severity:  trivial                            |   Keywords:  has-patch
  Focuses:  ui, accessibility, administration  |
-----------------------------------------------+---------------------------
 This documentation outlines the enhancement made to the daylight saving
 time (DST) transition notifications in WordPress, focusing on dynamically
 applying the site's configured date and time formats. The change ensures
 consistency with the site's overall formatting preferences and improves
 user experience by aligning DST transition messages with the site's
 design.

 == Code Changes ==

 '''Original Code:'''
 {{{
 if ( ! empty( $transitions[1] ) ) {
 echo ' ';
 $message = $transitions[1]['isdst'] ?
 /* translators: %s: Date and time. /
 __( 'Daylight saving time begins on: %s.' ) :
 / translators: %s: Date and time. */
 __( 'Standard time begins on: %s.' );
 printf(
 $message,
 '<code>' . wp_date( __( 'F j, Y' ) . ' ' . __( 'g:i a' ),
 $transitions[1]['ts'] ) . '</code>'
 );
 } else {
 _e( 'This timezone does not observe daylight saving time.' );
 }
 }}}

 '''Updated Code:'''
 {{{
 if ( ! empty( $transitions[1] ) ) {
 echo ' ';
 $message = $transitions[1]['isdst'] ?
 /* translators: %s: Date and time. /
 __( 'Daylight saving time begins on: %s.' ) :
 / translators: %s: Date and time. */
 __( 'Standard time begins on: %s.' );
 // Use site's configured date and time format directly in wp_date
 printf(
 $message,
 '<code>' . wp_date( get_option( 'date_format' ) . " " . get_option(
 'time_format' ), $transitions[1]['ts'] ) . '</code>'
 );
 } else {
 _e( 'This timezone does not observe daylight saving time.' );
 }
 }}}

 '''Key Changes:'''

     The date and time format for the DST transition message is now
 directly retrieved and applied by combining get_option( 'date_format' )
 and get_option( 'time_format' ) within the wp_date function call.
     This change ensures the DST transition notifications use the site's
 current date and time settings, promoting consistency and adaptability to
 user preferences.

 '''Internationalization:'''
 The use of __() and _e() functions for message translation remains
 unchanged, preserving the capability for these strings to be translated
 into different languages, supporting WordPress's internationalization
 framework.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60682>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list