Opened 5 years ago

Closed 4 years ago

#12575 closed bug (fixed)

Tracker ignores 24 hour format

Reported by: markh Owned by: pulkomandy
Priority: normal Milestone: R1
Component: Applications/Tracker Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

I set the time format to 24 hour in the Locale preferences in the Formatting tab, but Tracker keeps using AM and PM times, even if I restart Tracker.

I would expect Tracker to use the 24 hour formatting as well.

Attachments (1)

0001-Fix-24-hour-format-for-DateTimeFormats.patch (3.1 KB ) - added by markh 4 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 by jessicah, 5 years ago

What revision and architecture are you using? I can toggle the 12/24 hour option and the change is reflected instantaneously in Tracker -- not even requiring a restart.

comment:2 by diver, 5 years ago

Milestone: R1/beta1R1

comment:3 by markh, 5 years ago

Revision hrev49950. Deskbar does switch to a 24 hour format, but Tracker does not.

comment:4 by markh, 5 years ago

Had to reinstall the whole system due to BFS corruption, so I downloaded the latest nightly (hrev50032) onto an usb stick, reformatted my disk and reinstalled onto it. Went to Locale preferences -> Formatting and selected "24 hour" in Time section. Deskbar immediately switched to 24 hour time, but Tracker did not. Tried a reboot, but this did not help.

comment:5 by markh, 4 years ago

patch: 01

comment:6 by markh, 4 years ago

No idea how it used to work, but it was broken now. Added a patch that corrects the problem. Tracker will now pick up the 24 hour format. It will open new windows with the new format, but already opened windows stay with the old format. I don't think this ever worked otherwise. Perhaps a separate ticket can be created if this is wanted.

comment:7 by korli, 4 years ago

Owner: changed from axeld to pulkomandy
Status: newassigned

The patch touches the locale kit.

comment:8 by pulkomandy, 4 years ago

I don't remember this part of the code very well, but:

  • If fExplicitUse24HourClock is CLOCK_HOURS_UNSET, there should be no need to change the format, as the one from the locale will be used.
  • Using FormatUsesAmPm(outFormat); for detecting a 24 hour clock is a bit dangerous (it's possible to have 12 hour clock and no AM/PM indicator). I would write a method similar to FormatUsesAmPm, detecting the k,K,h,H characters in the format instead.
  • Anyway, there should be no need to check that, because the "coerce" method will not make any change to the format if it already is as expected

comment:9 by markh, 4 years ago

I copied this part from the GetTimeFormat function above it. I must say I did not look into detail if it was correct, but it did what I expected. Does it need a good review?

comment:10 by pulkomandy, 4 years ago

I can see some uses for a 12 hour format without AM/PM marker (possibly on some alarm clocks, for example). So, it looks like it is a good idea to allow for that possibility.

Also, in general, avoid copypasting things. If they are useful in two places, try to extract them in a method that can be reused in both :)

comment:11 by markh, 4 years ago

Changed the patch by extracting the common code into a method.

Btw, there are cases where the 24 hour clock already works in Tracker, but I think that is the case where the locale has that normally set. In those cases, the 12 hour clock does not work. For example, setting formatting to English (Netherlands) switches to 24 hour format in Tracker, but you cannot switch it to 12 hour format with the available option. The other way around goes for English (United States). This patch should fix that.

comment:12 by markh, 4 years ago

Is there something that needs to be done before this patch can be committed?

comment:13 by waddlesplash, 4 years ago

Resolution: fixed
Status: assignedclosed

Applied in hrev50361. Thanks!

Note: See TracTickets for help on using tickets.