|Summary:||Wishlist: [patch] Make Sys.timezone() work on Debian|
|Product:||R||Reporter:||Mikko Korpela <mvkorpel>|
Description Mikko Korpela 2016-11-29 12:22:02 UTC
Created attachment 2195 [details] Suggested patch When the TZ environment variable is not set, Sys.timezone() returns NA on recent (i.e. not ancient) versions of Linux distributions derived from Debian (unless they choose to modify this behavior). On these systems, /etc/localtime is not a symbolic link from which the name of the time zone can be extracted, but a regular file (copy of the time zone description). Instead, /etc/timezone contains the name of the time zone.  The attached patch reads /etc/timezone and checks that the corresponding time zone file exists in /usr/share/zoneinfo, and that the latter is of the same size as /etc/localtime (likely a copy of the same file). If so, the name read from /etc/timezone is returned. This whole code branch is only entered if the previous time zone detection methods fail. This was tested on Ubuntu 14.04.5 LTS. After applying the patch, the result of Sys.timezone() on this computer is "Europe/Helsinki" which matches the pre-patch result on my old Macbook (OS X 10.7.5).  https://wiki.debian.org/TimeZoneChanges > sessionInfo() R Under development (unstable) (2016-11-29 r71700) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 14.04.5 LTS locale:  LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C  LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8  LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8  LC_PAPER=en_US.UTF-8 LC_NAME=C  LC_ADDRESS=C LC_TELEPHONE=C  LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages:  stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached):  compiler_3.4.0 tools_3.4.0
Comment 1 Dirk Eddelbuettel 2016-11-29 16:59:40 UTC
Thumbs up. That is essentially what my micropackage 'gettz' does but as Duncan M remarked when he approved the initial CRAN upload, the change really belongs into base R.
Comment 2 Martin Maechler 2016-12-30 16:16:51 UTC
Thank you, Mikoo, very much. This has been fixed already > 3 weeks ago, r71729 | maechler | 2016-12-05 both in R-devel and R-patched