[R] how to calculate time offset between timezones?

Armstrong, Whit whit.armstrong at highbridge.com
Thu Jan 10 17:02:07 CET 2008


well, strangely,  ISOdatetime(2008,1,1,1,0,0,tz="AST") creates a UTC
timezone date on my system:

> ISOdatetime(2008,1,1,1,0,0,tz="AST")
[1] "2008-01-01 01:00:00 UTC"
> 

and if you compare the numeric values of the UTC datetime and the GMT
datetime, the are definitely the same:

> as.numeric(ISOdatetime(2008,1,1,1,0,0,tz="AST"))
[1] 1199149200
> as.numeric(ISOdatetime(2008,1,1,1,0,0,tz="GMT"))
[1] 1199149200
> 

I think the failure to recognize AST may have something to with the
timzones listed in /usr/share/zoneinfo (on Ubuntu linux) where I found
AST4:

whit at spartan:~$ find /usr/share/zoneinfo -name "AST*"
/usr/share/zoneinfo/SystemV/AST4
/usr/share/zoneinfo/SystemV/AST4ADT
/usr/share/zoneinfo/right/SystemV/AST4
/usr/share/zoneinfo/right/SystemV/AST4ADT
/usr/share/zoneinfo/posix/SystemV/AST4
/usr/share/zoneinfo/posix/SystemV/AST4ADT


and when I use it as the tz argument:

> ISOdatetime(2008,1,1,1,0,0,tz="AST4")
[1] "2008-01-01 01:00:00 AST"
> 

and

> ISOdatetime(2008,1,1,1,0,0,tz="AST4") -
ISOdatetime(2008,1,1,1,0,0,tz="GMT")
Time difference of 4 hours
> 


-Whit


> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of dankelley
> Sent: Thursday, January 10, 2008 10:21 AM
> To: r-help at r-project.org
> Subject: [R] how to calculate time offset between timezones?
> 
> 
> #QUESTION#
> 
> Is there a way to calculate the offset between timezones, 
> e.g. from "AST" to "GMT"?
> 
> #DETAILS# 
> 
> I am working with data files that use local time, and that 
> indicate the timezone by e.g. "AST" (Atlantic Standard Time, 
> my local time) in a header. 
> I was guessing that
> 
> > ISOdatetime(2008,1,1,1,0,0,tz="GMT") -
> > ISOdatetime(2008,1,1,1,0,0,tz="AST")
> 
> would work, but it gives a difference of 0.  However, when I do
> 
> > ISOdatetime(2008,1,1,1,0,0,tz="GMT") - ISOdatetime(2008,1,1,1,0,0)
> 
> I get a -4h offset, which is correct.  The odd thing is, I am 
> in AST time, as shown by the following.
> 
> > ISOdatetime(2008,1,1,1,0,0)
> [1] "2008-01-01 01:00:00 AST"
> 
> #SYSTEM#
> 
> Mac OS X system, with R 2.6.1 
> 
> #PS#
> 
> I am aware that this sort of thing is system dependent, and 
> so there may not be a general solution.  But even if I can 
> only get it working on my own particular system, I'd be happy!
> --
> View this message in context: 
> http://www.nabble.com/how-to-calculate-time-offset-between-tim
> ezones--tp14736453p14736453.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 




This e-mail message is intended only for the named recipient(s) above. It may contain confidential information. If you are not the intended recipient you are hereby notified that any dissemination, distribution or copying of this e-mail and any attachment(s) is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender by replying to this e-mail and delete the message and any attachment(s) from your system. Thank you.



More information about the R-help mailing list