Make WordPress Core

Opened 2 months ago

Closed 2 months ago

#60682 closed enhancement (wontfix)

Use configured date and time format in daylight saving time notice

Reported by: reklwera's profile reklwera Owned by:
Milestone: Priority: normal
Severity: trivial Version:
Component: Administration Keywords:
Focuses: Cc:

Description

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.

Attachments (1)

options-general.php (20.7 KB) - added by reklwera 2 months ago.
This is the options-general.php file with the chnages included

Download all attachments as: .zip

Change History (2)

@reklwera
2 months ago

This is the options-general.php file with the chnages included

#1 @swissspidy
2 months ago

  • Component changed from Options, Meta APIs to Administration
  • Focuses ui accessibility administration removed
  • Keywords has-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
  • Summary changed from Enhanced Dynamic Date and Time Formatting for DST Transition Notifications to Use configured date and time format in daylight saving time notice
  • Version trunk deleted

Hi there and thanks for opening this ticket.

Unfortunately the GPT-written description is not really helpful and does not actually explain the suggested enhancement. Also, I recommend checking out https://make.wordpress.org/core/handbook/tutorials/trac/submitting-a-patch/ to see how to create patch files for suggested changes. That makes it easier to see the difference and apply the change locally.

From what I understand when looking at the code sample, you suggest using the configured date_format and time_format values for the "Daylight saving time begins on: %s" / "Standard time begins on: %s." sentences.

I don't think that makes sense. date_format could be changed by the user to just show the year (Y), which would then make this sentence pretty useless because it's lacking the day & month.

date_format and time_format in WordPress are not meant to be applied everywhere there is a date. They're mostly intended for the front end, and not the admin.

As such, I am suggesting to close this as a wontfix.

Note: See TracTickets for help on using tickets.