From ripley at stats.ox.ac.uk  Mon Nov 22 08:31:02 2004
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon Nov 22 08:31:13 2004
Subject: [Rd] strptime() bugs?
In-Reply-To: <1101090880.4260.12.camel@localhost.localdomain>
References: <1101090880.4260.12.camel@localhost.localdomain>
Message-ID: <Pine.LNX.4.61.0411220728190.22893@gannet.stats>

The bug is in your (unstated) OS, probably in its locale handling.
Does not happen on Solaris, Linux or Windows for me.

In any case, why not use as.Date?

On Mon, 22 Nov 2004, Juan Santiago Ramseyer wrote:

> strptime return wrong data?, look the R session.
>
>
> # datetxt: vector of date in text format
>> datetxt <- c("1939-Oct-06 00:00:00", "1939-Oct-07 00:00:00",
>               "1939-Oct-08 00:00:00", "1939-Oct-09 00:00:00")
>
>> datehour <- strptime(datetxt,format= "%Y-%b-%d %H:%M:%S")
>> datehour
> [1] "1939-10-06 00:00:00" "1939-10-07 00:00:00" "1939-10-08 01:00:00"
> [4] "1939-10-09 00:00:00"
>
> # look value of datehour[3] element, where hour output equal 01:00:00,
> # but hour input equal 00:00:00.

Is there a DST issue in your unstated timezone?

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] strptime() bugs?
Prof Brian Ripley