[as.POSIXlt]: Incorrect conversion only for some specific date/time (PR#8654)

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

[as.POSIXlt]: Incorrect conversion only for some specific date/time (PR#8654)

aziz.chaouch
Full_Name: Aziz Chaouch
Version: 2.2.1
OS: XP/2000
Submission from: (NULL) (132.156.89.240)


Hi,

I'm not sure this is a "bug" but here is the problem:

I'm using the function as.POSIXlt to convert character strings into time
objects. I'm using date format as "YYYY/M/D HH:MM" such as as.POSIXlt("1999/6/7
13:30"). Most of the time, this works fine. However for some reasons, some
specific dates such as "2000/4/2 02:00" are not correctly converted with respect
to hours (the converted hour is 01:00 while the input was 02:00). Look for the
result in R:

> as.POSIXlt("2000/4/2 02:00")
[1] "2000-04-02 01:00:00"

Strangely, other hours are converted correctly:

> as.POSIXlt("2000/4/2 01:00")
[1] "2000-04-02 01:00:00"
> as.POSIXlt("2000/4/2 03:00")
[1] "2000-04-02 03:00:00"

I've only experienced this problem for some specific dates when the time is set
to 02:00.

The following list shows date/time that have problems so far but obviously there
are more:
"2000/4/2 02:00"
"2001/4/1 02:00"
"2002/4/7 02:00"
"2003/4/6 02:00"
"2004/4/4 02:00"
"2005/4/3 02:00"

Does anybody knows what's the problem? Am I missing something?

Thanks

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: [as.POSIXlt]: Incorrect conversion only for some specific date/time (PR#8654)

Gabor Grothendieck
Its due to daylight savings time in your time zone.  If you don't want
that then use the tz = "GMT" argument to specify GMT time zone as
GMT has no daylight savings time or set your entire session that way,
i.e. Sys.putenv(TZ = "GMT").

Also read the Help Desk article in R News 4/1 on dates and times.

On 3/3/06, [hidden email] <[hidden email]> wrote:

> Full_Name: Aziz Chaouch
> Version: 2.2.1
> OS: XP/2000
> Submission from: (NULL) (132.156.89.240)
>
>
> Hi,
>
> I'm not sure this is a "bug" but here is the problem:
>
> I'm using the function as.POSIXlt to convert character strings into time
> objects. I'm using date format as "YYYY/M/D HH:MM" such as as.POSIXlt("1999/6/7
> 13:30"). Most of the time, this works fine. However for some reasons, some
> specific dates such as "2000/4/2 02:00" are not correctly converted with respect
> to hours (the converted hour is 01:00 while the input was 02:00). Look for the
> result in R:
>
> > as.POSIXlt("2000/4/2 02:00")
> [1] "2000-04-02 01:00:00"
>
> Strangely, other hours are converted correctly:
>
> > as.POSIXlt("2000/4/2 01:00")
> [1] "2000-04-02 01:00:00"
> > as.POSIXlt("2000/4/2 03:00")
> [1] "2000-04-02 03:00:00"
>
> I've only experienced this problem for some specific dates when the time is set
> to 02:00.
>
> The following list shows date/time that have problems so far but obviously there
> are more:
> "2000/4/2 02:00"
> "2001/4/1 02:00"
> "2002/4/7 02:00"
> "2003/4/6 02:00"
> "2004/4/4 02:00"
> "2005/4/3 02:00"
>
> Does anybody knows what's the problem? Am I missing something?
>
> Thanks
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel