Re: [R] timezone problems

From: Uwe Ligges <ligges_at_statistik.uni-dortmund.de>
Date: Thu 07 Jul 2005 - 19:57:42 EST

Martin Keller-Ressel wrote:

> Thank you Don for your hints. I have checked my environment vairable TZ  
> again. But everything is set correctly. I think the problem is with  
> Sys.timezone(). Maybe it is a conflict between how my system formats the  
> time/date and what Sys.timezone() expects.
> This is what I get on my system:
> 
> 

>>Sys.getenv("TZ")
> 
>     TZ
> "GMT"
> 

>>Sys.time()
> 
> [1] "2005-07-07 07:32:39 GMT"
> 
> ## everything fine so far
> 
> 

>>Sys.timezone()
> 
> [1] NA
> 
> ## This is what Sys.timezone looks like:
> 

>>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
> 
> I dont understand why Sys.timezone doesn't use attr(z,"tzone") but tries  
> to read its (2+z$isdst)-th element.
> Of course it would be easy to write a workaround, but I wonder why nobody  
> else is having this problem.


I can confirm for R-2.1.1 under Windows NT 4.0 and it looks like a bug (somewhere down the way from as.POSIXlt). Don't have the time to look at it more closely, perhaps Brian knows it at once? If this is not already in the bug repository (please check at first), can you submit a report, please? Thanks!

Uwe Ligges

> best regards,
> 
> Martin Keller-Ressel
> 
> 
> 
> On Wed, 06 Jul 2005 14:45:25 -0000, Don MacQueen <macq@llnl.gov> wrote:
> 
> 

>>How did you set the TZ system variable?
>>If you did not use Sys.putenv(), try using it instead.
>>Otherwise, I think you have to ask the package maintainer.
>>
>>You may be misleading yourself by using Sys.time() to test whether TZ is
>>set.
>>What does Sys.getenv() tell you?
>>
>>I get a timezone code from Sys.time() even when TZ is not defined (see
>>example below).
>>(but I do have a different OS)
>>
>>
>>> Sys.timezone()
>>
>>[1] ""
>>
>>> Sys.time()
>>
>>[1] "2005-07-06 07:34:15 PDT"
>>
>>> Sys.getenv('TZ')
>>
>>TZ
>>""
>>
>>> Sys.putenv(TZ='US/Pacific')
>>> Sys.timezone()
>>
>>[1] "US/Pacific"
>>
>>> Sys.getenv('TZ')
>>
>> TZ
>>"US/Pacific"
>>
>>> Sys.time()
>>
>>[1] "2005-07-06 07:34:38 PDT"
>>
>>
>>> Sys.putenv(TZ='GMT')
>>> Sys.time()
>>
>>[1] "2005-07-06 14:35:45 GMT"
>>
>>
>>> version
>>
>> _ platform powerpc-apple-darwin7.9.0
>>arch powerpc os darwin7.9.0
>>system powerpc, darwin7.9.0 status
>>major 2 minor 1.1
>>year 2005 month 06
>>day 20 language R
>>At 9:55 AM +0000 7/5/05, Martin Keller-Ressel wrote:
>>
>>>Hi,
>>>
>>>Im using R 2.1.1 and running Code that previously worked (on R 2.1.0 I
>>>believe) using the 'timeDate' function from the fCalendar package. The
>>>code now throws an error:
>>>
>>>Error in if (Sys.timezone() != "GMT") warning("Set timezone to GMT!")
>>>
>>>However I have read the documentation of the fCalendar package and I
>>>have set my system variable TZ to GMT.
>>>I tracked the error down to the function Sys.timezone() which returns
>>>NA in spite of what Sys.time() returns.
>>>
>>>
>>>> Sys.timezone()
>>>
>>>[1] NA
>>>
>>>
>>>> Sys.time()
>>>
>>>[1] "2005-07-05 08:41:53 GMT"
>>>
>>>My version:
>>>
>>>
>>>> version
>>>
>>> _
>>>platform i386-pc-mingw32
>>>arch i386
>>>os mingw32
>>>system i386, mingw32
>>>status
>>>major 2
>>>minor 1.1
>>>year 2005
>>>month 06
>>>day 20
>>>language R
>>>
>>>Any help is appreciated,
>>>
>>>Martin Keller-Ressel
>>>
>>>
>>>---
>>>Martin Keller-Ressel
>>>Research Unit of Financial and Actuarial Mathematics
>>>TU Vienna
>>>
>>>______________________________________________
>>>R-help@stat.math.ethz.ch mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guide!
>>>http://www.R-project.org/posting-guide.html
>>
>>
> 
> 
>

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 07 20:02:48 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:19 EST