thlib / go-timezone-local

Get the full name of the local timezone
The Unlicense
14 stars 9 forks source link

Support chained symlinks in OpenWrt/linux #11

Open jetibest opened 3 weeks ago

jetibest commented 3 weeks ago

In OpenWrt I have a device where /etc/localtime is a symlink pointing to /tmp/localtime which consequently points to the right timezone.

Maybe you could put os.ReadLink into a loop (with a map memory to detect infinite loop). And/or (possibly at each step) check if the first letter of each continent/place is actually with an uppercase letter, which must be true for a timezone.

Current behavior is to simply return "tmp/localtime" which is incorrect.

FObersteiner commented 3 weeks ago

filepath.EvalSymlinks seems to do the trick; see PR