Get the Timezone Information

A function to retrieve the system timezone on Unix systems which has been found to find an answer when 'Sys.timezone()' has failed. It is based on an answer by Duane McCully posted on 'StackOverflow', and adapted to be callable from R. The package also builds on Windows, but just returns NULL. The functionality it offers was not available in R when the package was written, but has since been added which reduces the need for this package.


gettz: Get System Timezone Information

CI License CRAN Dependencies r-universe Downloads Last Commit

Original Motivation

Many date and time conversion need information about the local timezone. It is common to set the environment variable TZ. However, sometimes it is unset, and we need a fallback. Or maybe we just want a fallback to not always have to set the TZ variable by hand.

R has a helper function Sys.timezone() which queries the system timezone information. Sadly, we have seen it fail (possibly because /etc/localtime was not a symbolic link as it expected, but rather a copy of the corresponding (local) timezone metadata). Another issue is, once again, that the code which R uses here is sadly not accessible to users via a callable API for C or C++. So there is a need for something different---and Duane McCully provided just that in this StackOverflow answer. This package essentially adapted his code to be callable from R.

In the years since 2016 (when this was originally written), R itself became more robust so the packages for which this has been used no longer require it though anytime still suggests it.

Status

Works on Linux, expected to also work on Solaris and BSD, builds on OS X and Windows but only returns NULL due to the apparent lack of any programmatic interface. As noted in the preceding section, it should no longer be needed.

Windows could possibly be supported better by querying the registry. Contributions / pull requests would be welcomed on this.

Installation

The package is now on CRAN and can be installed via a standard

install.packages("gettz")

command.

Author

Dirk Eddelbuettel

License

GPL (>= 2)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("gettz")

0.0.6 by Dirk Eddelbuettel, 2 months ago


https://github.com/eddelbuettel/gettz/, https://dirk.eddelbuettel.com/code/gettz.html


Report a bug at https://github.com/eddelbuettel/gettz/issues


Browse source code at https://github.com/cran/gettz


Authors: Dirk Eddelbuettel [aut, cre] (ORCID:


Documentation:   PDF Manual  


GPL (>= 2) license



Suggested by anytime.


See at CRAN