[Rd] So-called 'bug' reports PR#8102 and PR#8103

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Aug 31 16:30:01 CEST 2005


Windows XP, R-devel (2005-08-31 r35465)

> tm <- ISOdate(2005, 08, 29, hour = 12, tz = "EST5EDT")
> tm
[1] "2005-08-29 12:00:00 EDT"
> tm + 0
[1] "2005-08-29 12:00:00 EDT"
> tm + 3600
[1] "2005-08-29 13:00:00 EDT"
> tm + c(0,1) * 3600
[1] "2005-08-29 12:00:00 EDT" "2005-08-29 13:00:00 EDT"

(R 2.1.1 gives on my machine

> tm + c(0,1) * 3600
[1] "2005-08-29 17:00:00 BST" "2005-08-29 18:00:00 BST"

which is also valid.)

> tstamp <- strptime("2005-07-31 23:59:59", format="%Y-%m-%d %H:%M:%S")
> attr(tstamp,"tzone") <- "EST5EDT"
> tstamp
[1] "2005-07-31 23:59:59 EST5EDT"
> tstamp-3600
[1] "2005-07-31 22:59:59 EDT"

so once the user error is corrected this works as expected even on 
Windows.  (Even with the user error it works correctly in FC3 Linux, 
which seems smart enough to know that EST5EDT was meant..)

On Windows, the routine used (_tzset) does not indicate user error, so 
there is no way for R to know that an invalid value was given. Linux 
(quoting POSIX) says `No errors are defined.' So users do need to read 
their system documentation.  For reference, see TZ in

http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html#tag_08


On Wed, 31 Aug 2005, Prof Brian Ripley wrote:

> Neither of these have reached me on R-devel (and only PR#8103 is on the 
> archive), and they seem to be the same error although neither mentions the 
> other.  That's 'odd', to quote one of them.
> 
> "EDT" is not a valid POSIX timezone (but, say, EST5EDT is).  R's docs are 
> quite clear that what happens with invalid inputs is system-specific. 
> (Windows seems often to run home to PST8PDT.)  You can have timezones 
> without DST, but not one permanently in DST.
> 
> In short, these were user errors compounded by unhelpful error-recovery by 
> the OS the users were using.
> 
> As to why tm + 3600 and tm + c(0, 1) * 3600 differ: one time is in one 
> timezone, but two can be in different timezones so they must be handled 
> differently.  This is handled slightly differently in the R-devel version, 
> which both the posting guide and the FAQ do ask you to try out (as well as 
> consulting the NEWS file which has a relevant entry).
> 
> Next time, please show some consideration for those who have to clear up 
> after you, and do as we ask in the posting guide and FAQ.

-- 
Brian D. Ripley,                  ripley at 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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list