Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't R recognize 'CST' as a valid timezone?

This code works:

ISOdatetime(2011,4,7,12,0,0, tz = "EST")

This code does not:

ISOdatetime(2011,4,7,12,0,0, tz = "CST")

I want the central time zone, with no adjustment for daylight savings. What am I doing wrong? Where can I find a table of timezones recognized by R?

edit: Thanks for the info Josh, but ISOdatetime(2011,3,13,2,0,0, tz = "America/Chicago") yields NA, and is unfortunately a value in my dataset. Any ideas how to deal with this? It seems like my dataset is on Chicago time, but does not observe daylight savings time.

like image 946
Zach Avatar asked Apr 07 '11 18:04

Zach


1 Answers

See ?timezone and the file, R_HOME/share/zoneinfo/zone.tab.

There's no such thing as "the central time zone, with no adjustment for daylight savings". The US central time zone has DST rules and they have changed over the years. You could always read in your dates as GMT, add 6 hours, then convert to CST6CDT.

> .POSIXct(ISOdatetime(2011,3,13,2,0,0, tz="GMT")+3600*6, tz="CST6CDT")
[1] "2011-03-13 03:00:00 CDT"
> .POSIXct(ISOdatetime(2011,3,13,2,0,0, tz="GMT")+3600*6, tz="America/Chicago")
[1] "2011-03-13 03:00:00 CDT"
like image 154
Joshua Ulrich Avatar answered Oct 23 '22 02:10

Joshua Ulrich