Jump to content

local time sans DST?


Go to solution Solved by quicksilvr,

Recommended Posts

I tried this code:

$a= '2023,6,12, 21,55,55,123'
$s&= 'a=' & $a & @LF

$a= StringSplit( $a, ',')

$fts= _Date_Time_EncodeFileTime( $a[2]*1,$a[3]*1,$a[1]*1, _
  $a[4]*1,$a[5]*1,$a[6]*1,$a[7]*1)
  
$s1= _Date_Time_FileTimeToStr( $fts,1)
$ftsL= _Date_Time_FileTimeToLocalFileTime ( $fts)
$s2= _Date_Time_FileTimeToStr( $ftsL,1)
$fts= _Date_Time_LocalFileTimeToFileTime ( $ftsL)
$s3= _Date_Time_FileTimeToStr( $fts,1)

$s&= 's1=' & $s1 & @LF
$s&= 's2=' & $s2 & @LF
$s&= 's3=' & $s3 & @LF
$s&= '' & @LF

Result:
a=2023,6,12, 21,55,55,123
s1=2023/06/12 21:55:55
s2=2023/06/12 22:55:55
s3=2023/06/12 21:55:55

According my local experience I have expected:
s2=2023/06/12 23:55:55

How do these functions work?
Is there only a constant local offset?
Or do they use regularly the current offset (which is 1h, no DST)?

 

Link to comment
Share on other sites

  • Solution

I guess the best solution is to use _Date_Time_SystemTimeToTzSpecificLocalTime with second parameter 0. On Windows 11 system, it seems possible to convert any globaltime (permanent offset 0) into localtime (including DST) according the current tz-offset-rule defined in system setting.

Background of this topic: I have a script, which logs measuring data within a duration of a few minutes up to a few days. I decided to name the generated data like this:
20240212_205555_123u60

When logging starts, the current offset minutes are requested from system, saved and applied to all subsequent data. This way the data can be easily assigned by humans and and calculated (regarding differences in milliseconds) by a program. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...