Modify

#4029 closed Bug (Fixed)

_Date_Time_SystemTimeToDateTimeStr() wrong output

Reported by: jchd18 Owned by: J-Paul Mesnage
Milestone: 3.3.17.0 Component: Standard UDFs
Version: 3.3.14.0 Severity: None
Keywords: Cc:

Description (last modified by jchd18)

The function _Date_Time_SystemTimeToDateTimeStr() has two related but distinct bugs.

Note: the timestamp returned by _Date_Time_GetSystemTime() is raw UTC.

Local $tST = _Date_Time_GetSystemTime()
ConsoleWrite(_Date_Time_SystemTimeToDateTimeStr($tST, 1, 0) & @LF)
ConsoleWrite(_Date_Time_SystemTimeToDateTimeStr($tST, 1, 1) & @LF)

produces the same output:

2024/09/26 12:23:46
2024/09/26 12:23:46

but the first should be shifted by timezone and DST settings. (I'm in France and currently UTC+02:00.)

Local $tST = _Date_Time_GetSystemTime()
ConsoleWrite(_Date_Time_SystemTimeToDateTimeStr($tST, 3, 0) & @LF)
ConsoleWrite(_Date_Time_SystemTimeToDateTimeStr($tST, 3, 1) & @LF)

produces a very wrong output:

2024-09-26T12:30:29-02:00
2024-09-26T12:30:29Z

The second output correctly displays the UTC time.
The first line has YMDhms wrong by 2 hours and timeshift should read "+02:00", hence the first line should be showing local time with offset from UTC, like this:

2024-09-26T14:30:29+02:00

The above reads "it's 14:30:29 local time, and offset from UTC is +2h". To compute UTC from that, one must subtract the offset from the timestamp.

The help file is ambiguous and even wrong on the role of parameter $iType.

Attachments (0)

Change History (6)

comment:1 by jchd18, 17 months ago

Component: AutoItStandard UDFs

comment:2 by jchd18, 17 months ago

Description: modified (diff)

comment:3 by jchd18, 17 months ago

Description: modified (diff)

comment:4 by J-Paul Mesnage, 17 months ago

Hi,
Thanks for the ticket but do you have a fix to propose?

comment:5 by jchd18, 17 months ago

Hi Jpm,
I'll have a look at it. But I first need to finish my own timescale UDF and, trust me, it isn't just cake.

I write down here preliminary notes.

First, GMT has no more any unambiguous meaning since 1972-01-01. The string "GMT" should be replaced by the official name "UTC" everywhere in source and help.

Then the purpose of the function here is to produce a datetime string. OK but which datetime? This is untold and the $iType parameter only tells if the input structure is Local or UTC.

It seems to me that we need another parameter to decide what the user wants (values for France at the time of writing, UTC+1 and currently +1h summertime):

A) the current UTC time string, e.g. "2024-09-28T12:00:00 UTC", with or without the " UTC" suffix

or

B) his Local timestring, e.g. "2024-09-28T14:00:00+02:00", with or without the "+02:00" offset to UTC

or

C) yet another datetime format to be decided.

Of course, $MS always making things tricky, the structure gives biais the other way, resp. -60 and -60 minutes (biais = UTC - Local). This means we have to subtract that biais from UTC to get local time. This is not done by the function. Also that biais sign should be reversed to be appended to a local time.

Last edited 17 months ago by jchd18 (previous) (diff)

comment:6 by J-Paul Mesnage, 11 months ago

Milestone: 3.3.17.0
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [13099] in version: 3.3.17.0

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.