Bug in DateAndTime fromUnixTime: ???

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

Bug in DateAndTime fromUnixTime: ???

jrm
When I execute :
DateAndTime fromUnixTime: 1569648600
The value I get is :    2019-09-28T05:30:00-07:00

This looks wrong to me because UNIX time is supposed to be in UTC and the value shows an offset of -07:00 hours which I assume is the offset for Mountain Standard Time in the US.

My understanding is that the UTC value should be 2019-09-28T05:30:00-00:00
and I would have to convert it to 2019-09-27T10:30:00-07:00 to get the local time.

If the method #fromUnixTime is expected to return a value with the local timezone offset, then the time value should be adjusted to local time to match the offset.

However, I don't think that a UNIX time value should be represented in anything but UTC and the application should decide when and how to modify it.

- jrm


Reply | Threaded
Open this post in threaded view
|

Re: Bug in DateAndTime fromUnixTime: ???

Nicola Mingotti

Hi,

I agree, there must be something wrong, the following example gets the time, converts it to Unix Epoch and then reads the Unix Epoch back in local time. It fails.

AFAICsay, the Unix epoch is correct.

----

DateAndTime now.
" 2019-09-28T02:10:32.361354-07:00"

(DateAndTime now) asUnixTime. 
" 1569662550"

DateAndTime fromUnixTime: 1569662550.
"2019-09-28T09:22:30-07:00"

----

bye
nicola




On 9/27/19 10:28 PM, John-Reed Maffeo wrote:
When I execute :
DateAndTime fromUnixTime: 1569648600
The value I get is :    2019-09-28T05:30:00-07:00

This looks wrong to me because UNIX time is supposed to be in UTC and the value shows an offset of -07:00 hours which I assume is the offset for Mountain Standard Time in the US.

My understanding is that the UTC value should be 2019-09-28T05:30:00-00:00
and I would have to convert it to 2019-09-27T10:30:00-07:00 to get the local time.

If the method #fromUnixTime is expected to return a value with the local timezone offset, then the time value should be adjusted to local time to match the offset.

However, I don't think that a UNIX time value should be represented in anything but UTC and the application should decide when and how to modify it.

- jrm


    



Reply | Threaded
Open this post in threaded view
|

Re: Bug in DateAndTime fromUnixTime: ???

David T. Lewis
Hi John-Reed,

I am guessing that you may be using a Squeak 5.2 release image. If
so, you will be happy with the upcoming Squeak 5.3 release which will
contain an update to the DateAndTime representation.

In Squeak trunk today, you will see this:

  | dt |
  dt := DateAndTime fromUnixTime: 1569648600.
  dt asPosixSeconds. "==> 1569648600"
  dt offset. "==> 0:00:00:00"
  dt. "==> 2019-09-28T05:30:00+00:00"

Dave


On Sat, Sep 28, 2019 at 02:29:23AM -0700, Nicola Mingotti wrote:

>
> Hi,
>
> I agree, there must be something wrong, the following example gets the
> time, converts it to Unix Epoch and then reads the Unix Epoch back in
> local time. It fails.
>
> AFAICsay, the Unix epoch is correct.
>
> ----
>
> DateAndTime now.
> " 2019-09-28T*02:10*:32.361354*-07:00*"
>
> (DateAndTime now) asUnixTime.
> " 1569662550"
>
> DateAndTime fromUnixTime: 1569662550.
> "2019-09-28T*09:22*:30*-07:00*"
>
> ----
>
> bye
> nicola
>
>
>
>
> On 9/27/19 10:28 PM, John-Reed Maffeo wrote:
> >When I execute :
> >DateAndTime fromUnixTime: 1569648600
> >The value I get is :?????? 2019-09-28T05:30:00-07:00
> >
> >This looks wrong to me because UNIX time is supposed to be in UTC and
> >the value shows an offset of -07:00 hours which I assume is the offset
> >for Mountain Standard Time in the US.
> >
> >My understanding is that the UTC value should be 2019-09-28T05:30:00-00:00
> >and I would have to convert it to 2019-09-27T10:30:00-07:00 to get the
> >local time.
> >
> >If the method #fromUnixTime is expected to return a value with the
> >local timezone offset, then the time value should be adjusted to local
> >time to match the offset.
> >
> >However, I don't think that a UNIX time value should be represented in
> >anything but UTC and the application should decide when and how to
> >modify it.
> >
> >- jrm
> >
>

>