Opened 9 years ago

Closed 8 years ago

Last modified 7 years ago

#3350 closed defect (fixed)

[PATCH] Time is not localized but in UTC

Reported by: elexis Owned by: elexis
Priority: Must Have Milestone: Alpha 21
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description

Currently the FormatMillisecondsIntoDateString function always returns the time in UTC (or GMT) and doesn't adapt to the local timezone (no matter how you define your language or country in the settings).

You can observe this issue in the lobby (chat timestamps) and in the savegame-loading-menu. The visual-replay-menu #3258 will also be affected.

Refs #1530 (outdated)

Attachments (3)

lobby_local_time.patch (1.0 KB ) - added by Imarok 8 years ago.
localize lobby chat timestamp (Based on r17929
lobby_local_time_v2.patch (3.9 KB ) - added by Imarok 8 years ago.
More general approach, fixing (hopefully) all places where non-localized time was used.
3350_local_time.zip (2.1 KB ) - added by Imarok 8 years ago.
backup of the correlating git branch

Download all attachments as: .zip

Change History (15)

comment:1 by leper, 9 years ago

Also note r16037 and #2938, so the proper fix would be to use actual dates.

comment:2 by elexis, 8 years ago

In 17929:

Display chat-timestamps in the lobby in the correct timezone, refs #3350.

comment:3 by elexis, 8 years ago

(The removal of L894-905 should have been committed in r17928 instead of r17929.)

comment:4 by Itms, 8 years ago

In 17941:

Revert r17928.
It breaks the Windows build by using time_t and it changes too many things to the way lobby messages are processed to be entirely safe to commit now.
Refs #3832.

As a side effect it reverts r17929, refs #3350.

comment:5 by Itms, 8 years ago

The fix above shows that we might face problems when using directly std::time and related functions on different platforms.

We should implement a CTime class for the engine that would allow us to fix a number of those date-time problems in a consistent and easily maintainable way.

comment:6 by Imarok, 8 years ago

Keywords: patch rfc added
Milestone: BacklogAlpha 21
Summary: Time is not localized but in UTC[PATCH] Time is not localized but in UTC

by Imarok, 8 years ago

Attachment: lobby_local_time.patch added

localize lobby chat timestamp (Based on r17929

by Imarok, 8 years ago

Attachment: lobby_local_time_v2.patch added

More general approach, fixing (hopefully) all places where non-localized time was used.

comment:7 by Imarok, 8 years ago

If committed, the wiki should be changed (wiki:Internationalization)

comment:8 by elexis, 8 years ago

Component: Core engineUI & Simulation
Priority: Should HaveMust Have

Perhaps the C++ function itself should be changed. Since it's a file about localization, it would make sense to add the ability to localize a timestamp to that place. Should get the approach confirmed by Itms.

in reply to:  8 comment:9 by Imarok, 8 years ago

Replying to elexis:

Perhaps the C++ function itself should be changed. Since it's a file about localization, it would make sense to add the ability to localize a timestamp to that place. Should get the approach confirmed by Itms.

Done: https://github.com/Imarok/0ad/tree/3350_local_time

comment:10 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 18725:

Use the local timezone when localizing UTC timestamps. Patch by Imarok, fixes #3350, refs #2938.
Thus show the correct time in the lobby, savegame and replay menu.

comment:11 by elexis, 8 years ago

Keywords: rfc removed

Thanks for the patch!

See also http://icu-project.org/apiref/icu4c/classicu_1_1TimeZone.html LocalizeDateTime which is used for the build timestamp returns the formatted time in the current local timezone. The ingame timesamp has always been printed in the current timezone by using a JS function.

by Imarok, 8 years ago

Attachment: 3350_local_time.zip added

backup of the correlating git branch

comment:12 by Imarok, 7 years ago

In 19180:

Durations over 1 hour aren't displayed correctly

Reviewed by: elexis

Differential Revision: https://code.wildfiregames.com/D44

refs #4418, #3350

Note: See TracTickets for help on using tickets.