From ripley at stats.ox.ac.uk  Mon Jul 11 08:59:06 2005
From: ripley at stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Mon, 11 Jul 2005 08:59:06 +0200 (CEST)
Subject: [Rd] Sys.timzone() returns NA - problem caused by as.POSIXlt?
	(PR#8003)
Message-ID: <20050711065906.5B36EA75A@slim.kubism.ku.dk>

This is not a bug in R: the documentation does say the result is 
OS-specific.

`GMT' is a not a proper timezone on Windows, so NA is a valid answer.
(Windows seems to use GMT to refer to the timezone of the UK, e.g.

> Sys.time()
[1] "2005-07-11 07:49:56 GMT Daylight Time"
> Sys.timezone()
[1] "GMT Daylight Time"

although I am in British Summer Time not GMT.)

I'll add yet another workaround for R-patched.


On Thu, 7 Jul 2005 mkeller at fam.tuwien.ac.at wrote:

> Full_Name: Martin Keller-Ressel
> Version: 2.1.1
> OS: Windows 2000
> Submission from: (NULL) (128.130.51.88)
>
>
> Sys.timezone() returns NA although the environment variable TZ is set to GMT
> and
> Sys.time() returns the correct time and date including the right timezone.
> The problem is probably due to as.POSIXlt() which is used by Sys.timezone().
>
> The problem has been confirmed by Uwe Ligges for R 2.1.1 on Windows NT 4.0.
> See below for a R session outlining the problem:
>
>
>> Sys.getenv("TZ")
>   TZ
> "GMT"
>> Sys.time()
> [1] "2005-07-07 10:28:11 GMT"
>> Sys.timezone()
> [1] NA
>
>> Sys.timezone
> function ()
> {
>    z <- as.POSIXlt(Sys.time())
>    attr(z, "tzone")[2 + z$isdst]
> }
> <environment: namespace:base>
>
>> z <- as.POSIXlt(Sys.time())
>> attributes(z)
> $names
> [1] "sec"   "min"   "hour"  "mday"  "mon"   "year"  "wday"  "yday"  "isdst"
>
> $class
> [1] "POSIXt"  "POSIXlt"
>
> $tzone
> [1] "GMT"
>
>> attr(z,"tzone")
> [1] "GMT"
>> z$isdst
> [1] 0
>> attr(z,"tzone")[2]
> [1] NA

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Sys.timzone() returns NA - problem caused by as.POSIXlt? (PR#8003)
ripley@stats.ox.ac.uk