Many date and time conversion need information about the localtimezone. It is common to set the environment variableTZ.However, sometimes it is unset, and we need a fallback. Or maybe we justwant a fallback to not always have to set theTZ variableby hand.
R has a helper functionSys.timezone() which queries thesystem timezone information. Sadly, we have seen it fail (possiblybecause/etc/localtime was not a symbolic link as itexpected, but rather a copy of the corresponding (local) timezonemetadata). Another issue is, once again, that the code which R uses hereis sadlynot accessible to users via a callable API for C orC++. So there is a need for something different—and Duane McCullyprovided just thatin this StackOverflowanswer. This package essentially adapted his code to be callablefrom R.
Works on Linux, expected to also work on Solaris and BSD, builds onOS X and Windows but only returnsNULL due to the apparentlack of any programmatic interface.
Windows could possibly be supported better by querying the registry.Contributions / pull requests would be welcomed on this.
Code, issue tickets, … are at theGitHub repo.
The package is now onCRANand can be installed via a standard
install.packages("gettz")command.
Dirk Eddelbuettel
GPL (>= 2)
Initially created: Sat Sep 10 09:23:53 CDT 2016
Last modified: Sun May 26 10:01:17 CDT 2024