[R] system time is 5 hours off in Windows

Setzer.Woodrow@epamail.epa.gov Setzer.Woodrow at epamail.epa.gov
Tue Jan 23 00:14:47 CET 2001


If I set TZ in the environment to something reasonable (I've used TZ=EST+5
and TZ="EST+5EDT,M4.1.0/2,M10.5.0/2"), R gives correct answers for the
current time, and returns a reasonable timezone string for Sys.time():

D:\home\setzer>set TZ=EST+5EDT,M4.1.0/2,M10.5.0/2

D:\home\setzer>echo %TZ%
EST+5EDT,M4.1.0/2,M10.5.0/2

D:\home\setzer>Rterm

R : Copyright 2001, The R Development Core Team
Version 1.2.1  (2001-01-15)

[...]

[Previously saved workspace restored]

> date()
[1] "Mon Jan 22 17:46:11 2001"
> Sys.time()
[1] "2001-01-22 17:46:16 EST"
> Sys.timezone()
[1] "EST+5EDT,M4.1.0/2,M10.5.0/2"
> q("no")

D:\home\setzer>time
Current time is  5:47:15.76p

If I unset TZ, then the timezone reported in R doesn't make sense, really.

D:\home\setzer>set TZ=

D:\home\setzer>echo %TZ%
ECHO is on

D:\home\setzer>Rterm
[...]

> Sys.time()
[1] "2001-01-22 22:49:49 Eas"
> Sys.timezone()
[1] "Eastern Daylight Time"

So now the time returned is UTC.  When I was experimenting with setting the
timezone, I inadvertantly included double quotes in the TZ string.  When I
asked for Sys.time(), the timezone part of the resulting string was \"Ea,
so the string being reported is just being copied unconditionally into the
output string.

I've found the warning in the documentation for as.POSIXct to try setting
TZ on UNIX-like systems if the POSIX functions give unusual results;
perhaps this should apply to Windows systems, too?  That doesn't explain
the return of date() which relies on the OS to set the time zone (and, when
I execute the same code as a stand-alone program, I get the correct system
time).  It is as if some startup code looks for TZ in the environment, and
if it is not there, sets it to a value which, perhaps, the system does not
recognize as valid, and defaults to GMT.

This is what I get inside Rgui when I query the TZ variable (I have not set
it in the environment):

> Sys.getenv("TZ")
                     TZ
"Eastern Daylight Time"

It seems to me that, if this is going to be used to set the time zone for
POSIX functions, it should look like one of the standard ways of specifying
a time zone (all I know about this is what I read in the libc manual about
the POSIX date-time functions, so I may be way off base here for the
Windows implementation).




R. Woodrow Setzer, Jr.                                            Phone:
(919) 541-0128
Experimental Toxicology Division                       Fax:  (919) 541-5394
Pharmacokinetics Branch
NHEERL MD-74; US EPA; RTP, NC 27711


                                                                                                                       
                    Woodrow                                                                                            
                    Setzer/RTP/USEPA/US@        To:     r-help at lists.R-project.org                                     
                    EPA                         cc:                                                                    
                    Sent by:                    Subject:     [R] system time is 5 hours off in Windows                 
                    owner-r-help at stat.ma                                                                               
                    th.ethz.ch                                                                                         
                                                                                                                       
                                                                                                                       
                    01/19/2001 04:49 PM                                                                                
                                                                                                                       
                                                                                                                       



Am I missing a configuration step?  The value returned by date() and
Sys.time() is five hours later than the system time.  Furthermore,
Sys.timezone() returns Eastern Daylight Time, whereas we are really
currently in Eastern Standard Time.  I am running:

         _
platform i386-pc-mingw32
arch     x86
os       Win32
system   x86, Win32
status
major    1
minor    2.1
year     2001
month    01
day      15
language R


R. Woodrow Setzer, Jr.                                            Phone:
(919) 541-0128
Experimental Toxicology Division                       Fax:  (919) 541-5394
Pharmacokinetics Branch
NHEERL MD-74; US EPA; RTP, NC 27711

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._




-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list