Hi all, in R I have?Sys.timezone() function to get the current working Time zone. However I want to have a vector to get the list of all available time zones, like say, LETTERS gives me all letters. Is there any function like that? Thanks in advance,
List of all times zones in R
4 messages · Maithula Chandrashekhar, Joe King, Brian Ripley +1 more
Type in letters into command prompt
letters
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" "o" "p" "q" "r" "s" [20] "t" "u" "v" "w" "x" "y" "z" Joe King 206-913-2912 jp at joepking.com Ad astra per aspera ? ?Through hardships to the stars? -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Maithula Chandrashekhar Sent: Sunday, January 30, 2011 10:08 PM To: r-help at r-project.org Subject: [R] List of all times zones in R Hi all, in R I have?Sys.timezone() function to get the current working Time zone. However I want to have a vector to get the list of all available time zones, like say, LETTERS gives me all letters. Is there any function like that? Thanks in advance, ______________________________________________ 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.
On Mon, 31 Jan 2011, Maithula Chandrashekhar wrote:
Hi all, in R I have?Sys.timezone() function to get the current working Time zone. However I want to have a vector to get the list of all available time zones, like say, LETTERS gives me all letters. Is there any function like that?
No, because the timezones are not 'in R': they are in your OS (as ?Sys.timezone stresses). Many OSes do not even has a function to give you their name for the current timezone, let alone all others. Note too that an OS often has many names for a single time zone. Despite the posting guide, you have given us no details of your system. On Windows, the help page says A file listing most known time zones can be found at R_HOME/share/zoneinfo/zone.tab.
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
On Jan 31, 2011, at 1:07 AM, Maithula Chandrashekhar wrote:
Hi all, in R I have Sys.timezone() function to get the current working Time zone.
Only on some systems.
However I want to have a vector to get the list of all available time zones, like say, LETTERS gives me all letters. Is there any function like that?
On a Mac (10.5.8) the timezone information is in /usr/share/timezone/
which also has a file named "zone.tab"
This is the header of that file:
> readLines("/usr/share/zoneinfo/zone.tab")
[1] "# <pre>"
[2] "# @(#)zone.tab\t8.28"
[3] "# This file is in the public domain, so clarified as of"
[4] "# 2009-05-17 by Arthur David Olson."
[5] "#"
[6] "# TZ zone descriptions"
[7] "#"
[8] "# From Paul Eggert (1996-08-05):"
[9] "#"
[10] "# This file contains a table with the following columns:"
[11] "# 1. ISO 3166 2-character country code. See the file
`iso3166.tab'."
[12] "# 2. Latitude and longitude of the zone's principal location"
[13] "# in ISO 6709 sign-degrees-minutes-seconds format,"
[14] "# either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,"
[15] "# first latitude (+ is north), then longitude (+ is east)."
[16] "# 3. Zone name used in value of TZ environment variable."
[17] "# 4. Comments; present if and only if the country has
multiple rows."
[18] "#"
[19] "# Columns are separated by a single tab."
[20] "# The table is sorted first by country, then an order within
the country that"
[21] "# (1) makes some geographical sense, and"
[22] "# (2) puts the most populous zones first, where that does not
contradict (1)."
[23] "#"
[24] "# Lines beginning with `#' are comments."
[25] "#"
[26] "#country-"
[27] "#code\tcoordinates\tTZ\t\t\tcomments"
[28] "AD\t+4230+00131\tEurope/Andorra"
snipped the remaining 400 lines
In addition in that directory, there are separate subdirectories for
each timezone and the number of such entries exceeded the number of
lines in zone.tab. Attached is a file with the names of the
subdirectories with the common stem removed produced by with this code
acting on a pasted screen scrape of a terminal session:
> TZlist <- strsplit(gsub("/usr/share/zoneinfo/", "", gsub("\\\n",
",", txt)), ",")
> write.table(TZlist, file="TZlist.txt")
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: TZlist.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110131/3d6c0953/attachment.txt>
-------------- next part --------------
This is its tail:
[570] "US/Alaska"
[571] "US/Aleutian"
[572] "US/Arizona"
[573] "US/Central"
[574] "US/East-Indiana"
[575] "US/Eastern"
[576] "US/Hawaii"
[577] "US/Indiana-Starke"
[578] "US/Michigan" # my birth state, its timezone rules seem to
change with every election.
[579] "US/Mountain"
[580] "US/Pacific"
[581] "US/Samoa"
[582] "UTC"
[583] "Universal"
[584] "W-SU"
[585] "WET"
[586] "Zulu" # which I seem to remember is a synonym for UTC
Sys.timezone doesn't actually produce useful information in all cases
(and this is documented behavior).
> Sys.timezone()
[1] ""
> Sys.getenv("TZ")
TZ
""
You can change the timezone on a Mac (and probably on other systems)
with Sys.setenv():
> Sys.time()
[1] "2011-01-31 08:35:17 EST"
> Sys.setenv("TZ"="US/Samoa")
> Sys.time()
[1] "2011-01-31 02:35:52 SST"
> Sys.setenv("TZ"="US/Eastern")
> Sys.time()
[1] "2011-01-31 08:37:07 EST"
David Winsemius, MD West Hartford, CT