Ticket #6913 (new enhancement)

Opened 2 months ago

Last modified 2 months ago

Make the editor's time format (24-hour vs. 12-hour clock) configurable per user

Reported by: regulatethis Assigned to: anonymous
Priority: low Milestone: 2.6
Component: General Version:
Severity: normal Keywords: has-patch
Cc:

Description

A recent thread on the wp dev mailing list brought up the fact that some people have a hard time understanding 24-hour time and so are confused by the editor's usage of a 24-hour clock when modifying a post's or page's timestamp.

One potential solution for this issue is to make a profile options which lets a user change the way the editor displays its timestamp.

If this option is set to 24-hour, then the editor behaves as it does now, displaying the timestamp in 24 hour time e.g. 17:43. This option is the default in all cases.

If this option is set to 12-hour, then the editor displays the timestamp in 12 hour time e.g. 5:43pm. The user can then change the time and the meridiem (am/pm) using a dropdown box.

All internal representations of a post or page timestamp remain unchanged. Only the display of the timestamp is changed if the user chooses 12-hour time. In this case, code in post.php converts the time back to a 24-hour representation before committing the change to the db.

Attachments

time_format_6913.diff (7.1 kB) - added by regulatethis on 05/04/08 16:39:30.
Update of patch, fixing so 24 hour clock displays as default for an existing user without the option set (Thanks Alexander Beutl for pointing this out)
time_format_6913_rev2.diff (10.3 kB) - added by regulatethis on 05/05/08 01:14:51.

Change History

05/04/08 09:31:41 changed by regulatethis

This is my first attempt at non-trivial WP hacking. This is a convenience feature (I understand 24-hour time perfectly ;) ) but might be a nice option.

Please comment if I've done anything stupid or with any improvements. I've run quite a few tests on this code and it seems to be working fine but then again I don't have that much experience with WP, so please test this!

05/04/08 11:26:38 changed by ozh

Instead of a per-user setting, I'd rather see a global setting that can be per-user overridden.

05/04/08 16:39:30 changed by regulatethis

  • attachment time_format_6913.diff added.

Update of patch, fixing so 24 hour clock displays as default for an existing user without the option set (Thanks Alexander Beutl for pointing this out)

05/05/08 01:14:51 changed by regulatethis

  • attachment time_format_6913_rev2.diff added.

05/05/08 01:19:49 changed by regulatethis

Rev 2 of my patch:

- Editor time format is now a global setting under Settings > General
- User profiles can either 'default' to the global setting or override with 12 or 24 hour
- Global settings defaults to 24-hour, and user profiles default to using global

Fixed:
- Bug when entering "12" for the hour
- Conflicting usage of "time_format" as an option name in wp_usermeta nad wp_options

05/05/08 17:55:02 changed by regulatethis

  • keywords set to has-patch.
  • milestone changed from 2.7 to 2.6.

05/05/08 19:15:24 changed by ryan

12/24 preference can be derived from the "Time Format" setting. 'g' or 'h' in the format specifier indicates a 12 hour prefence. 'G' or 'H' indicates a 24 hour preference. Ideally, however, the post editor would use an inline date/time picker built on jQuery.

05/05/08 19:24:04 changed by regulatethis

That's the time format for times displayed in most areas of the blog, but this doesn't affect the time format used for scheduling or editing a post's timestamp, which was always in 24-hour format.

My patch addresses the latter case.

Or am I missing something? :)

05/05/08 20:02:35 changed by ryan

I'm just saying we don't need another time setting. We have too many time settings as is. This will probably all be moot once we add jQuery date/time picker that will be more friendly. If we want to offer a 12/24 option with the new picker, we can put a checkbox inline with the picker that saves the preference in a cookie or in usermeta and updates the time display on the fly.

05/05/08 20:18:35 changed by regulatethis

Fair enough.

That said, it's a global setting that defaults to the current behavior and can be overriden if a user so desires (so I can't really see this cluttering/confusing anything).

As far as it being moot - if the jQuery date/time picker is already in the works then yeah I agree there's no point in making this change now. Otherwise, this could be a simple and quick enhancement until the jQuery stuff is put together and tested.