timestamp asSeconds/fromSeconds (Was: Re: vw 7.7 support for Windows 2000)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

timestamp asSeconds/fromSeconds (Was: Re: vw 7.7 support for Windows 2000)

kobetic
"Holger Kleinsorgen"<[hidden email]> wrote:

> Date: May 6, 2010 2:05:55 PM
> From: Holger Kleinsorgen <[hidden email]>
> To: [hidden email]
> Subject: [vwnc] timestamp asSeconds/fromSeconds (Was: Re: vw 7.7 support for Windows 2000)
>
> Am 06.05.2010 17:35, schrieb [hidden email]:
> > "Holger Kleinsorgen"<[hidden email]>  wrote:
> >> I'm wondering under which circumstances there will ever be a difference
> >> between Timezone null and Timezone default when using #asSeconds or
> >> #fromSeconds:. #asSeconds and #fromSeconds do not involve any
> >> timezone-related api (#universalToLocal:, #localToUniversal:) when using
> >> the system timezone.
> >
> > Not sure what you mean, conversion between timestamps and second counts most definitely should and does involve the timezone, otherwise you can't account for DST or leap seconds or years.
> >
> Timezone-related adjustements are only done when sending
> #localToUniversal: / #localToUniversal: (like "Timestamp now" does).

Ah I get your point now. I have to admit I keep making the same mistake, Timestamp>>asSeconds assumes UTC timestamp, consequently there won't be any difference between Timestamp null and Timestamp default in that regard. So my claim that Steven's workaround will cause up to 12 hours of error is false. My bad.

That of course does make the idea of some sort of transparent failover for second count transformations much more attractive. I'll make an AR. Thanks for the clue-by-four!

Martin
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: timestamp asSeconds/fromSeconds (Was: Re: vw 7.7 support for Windows 2000)

Steven Kelly
[vwnc] timestamp asSeconds/fromSeconds (Was: Re: vw 7.7 support for Windows 2000)
Looks like the next-to-last line should set systemTimestamp using TimeZone default, not TimeZone null.
Steve

From: [hidden email] on behalf of Holger Kleinsorgen
Sent: Thu 06/05/2010 21:05
To: [hidden email]
Subject: [vwnc] timestamp asSeconds/fromSeconds (Was: Re: vw 7.7 support for Windows 2000)

Am 06.05.2010 17:35, schrieb [hidden email]:
> "Holger Kleinsorgen"<[hidden email]>  wrote:
>> I'm wondering under which circumstances there will ever be a difference
>> between Timezone null and Timezone default when using #asSeconds or
>> #fromSeconds:. #asSeconds and #fromSeconds do not involve any
>> timezone-related api (#universalToLocal:, #localToUniversal:) when using
>> the system timezone.
>
> Not sure what you mean, conversion between timestamps and second counts most definitely should and does involve the timezone, otherwise you can't account for DST or leap seconds or years.
>

1601 to: 30827 do: [: year |
   1 to: 12 do: [ : month |
     | timestamp nullSeconds systemSeconds nullTimestamp systemTimestamp  |
     timestamp := (Date newDay: 1 monthNumber: month year: year)
asTimestamp.
     nullSeconds := TimeZone null timestampToSeconds: timestamp.
     systemSeconds := TimeZone default timestampToSeconds: timestamp.
     nullSeconds = systemSeconds ifFalse: [ self halt ].
     nullTimestamp := TimeZone null secondsToTimestamp: nullSeconds.
     systemTimestamp := TimeZone null secondsToTimestamp: nullSeconds.
     nullTimestamp = systemTimestamp ifFalse: [ self halt ].
   ].
].


The code above never halts.

On Windows, "timestamp asSeconds" boils down to a call to
SystemTimeToFileTime(). MSDN says:

"Converts a system time to file time format. System time is based on
Coordinated Universal Time (UTC).". FILETIME is based on UTC, too.

So no timezone-related adjustements are made (DST etc.). It only
converts a UTC FILETIME to a UTC SYSTEMTIME.

Timezone-related adjustements are only done when sending
#localToUniversal: / #localToUniversal: (like "Timestamp now" does).
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc