From sokol at insa-toulouse.fr  Tue May 16 12:58:00 2017
From: sokol at insa-toulouse.fr (Serguei Sokol)
Date: Tue, 16 May 2017 12:58:00 +0200
Subject: [Rd] tweaking Sys.timezone()
Message-ID: <cc29218b-a0e8-cdc1-e10e-973e8067f119@insa-toulouse.fr>

Hi,

On my system (Linux, Mageia 5) Sys.timezone() returns NA but
with a minor tweak it could work as expected, i.e. returning "Europe/Paris".

Here is the problem. At some moment it does

  lt <- normalizePath("/etc/localtime")

On my system /etc/localtime is a symlink pointing to
/usr/share/zoneinfo/Europe/Paris. So far so good.
With the next two operations the good answer should be found:

  if (grepl(pat <- "^/usr/share/zoneinfo/", lt)) sub(pat, "", lt)

Unfortunately, on my system "/usr/share" is also a simlink
so lt resolves to "/home/local/usr_share/zoneinfo/Europe/Paris"
and not to "/usr/share/zoneinfo/Europe/Paris".
So the test above fails.
As the keyword in this story is zoneinfo, could we modify the
pat to look as

   if (grepl(pat <- "^.*/zoneinfo/", lt)) sub(pat, "", lt)

?
In this way, we don't make assumption where exactly
"zoneinfo/*" resides. We have found it, no matter where, so use it.

Hoping it could find its way into a next R release.

Best,
Serguei.



[Rd] tweaking Sys.timezone()
Serguei Sokol