Closed micheloosterhof closed 3 years ago
Hey, thanks for reporting this! We don't have a lot of OSX computers to test on, so it's nice to get reports.
This is a tough one, since not all Linuxes will follow OSX's behavior with /etc/localtime
. For example, while my Debian box shows similar behavior (where /etc/localtime
is symlinked to somewhere more descriptive), it is common (I believe) with RedHat to simply copy a timezone in the the /etc/localtime
, which would break the awk
/cat
system.
However, I think you're right that using the env TZ
variable is better.
I have come up with a very janky solution:
-e TZ="$$( printf Etc/GMT%+d\\n "$$(( -1* $$(echo 0 $$(date +%z) | bc) / 100 ))" )" \
which I believe may work..?
I'd be good to try it on your commandline first:
printf Etc/GMT%+d\\n "$(( -1* $(echo 0 $(date +%z) | bc) / 100 ))"
it should print something like Etc/GMT-10
.
I have put it into the Makefile, and it seems to work on my Debian machine.
It's a bit of a hack, relying on the older, but still compatible, versions of timezones. More info here: https://github.com/eggert/tz/blob/master/etcetera
The script uses the date
program to get the relative difference to GMT (I believe), then parses it through bc
to get it to a usable int, then reverses the sign, and divides by 100 :sweat_smile:
Anyway, can you give it a try, and tell me if it works, and if not, what the commandline outputs?
$ printf Etc/GMT%+d\\n "$(( -1* $(echo 0 $(date +%z) | bc) / 100 ))"
Etc/GMT-8
This is good, but on changing to or from daylight savings time the docker container will not automatically migrate to this. The impact of this will probably be small.
Sorry for the mega-delay - we have a PR up now, which should fix this issue. Much simpler than the other options I mentioned, so that's a bonus too. Should be merged soon.
Instead of mounting the localtime file, pass the
TZ
variable to Docker. This may work on Linux as well.The
cut
works on my system, but 8-9 is arbitrary, maybe better written in awk asls -la /etc/localtime | awk -F '/' '{ printf "%s/%s\n", $(NF - 1), $NF }'