Closed alekspickle closed 10 months ago
time_tz::system::get_timezone()
uses /etc/localtime
can you check to what file /etc/localtime
points to in your docker?
Note: if all you're after is to get the current system time in local time and not the actual timezone, you can check out bp3d-os
with the time
feature.
Fair enough, but still it kinda unexpected. The content of all images I checked:
root@0e903dfdb4c9:/app# cat /etc/localtime
TZif2UTCTZif2UTC
UTC0
Fair enough, but still it kinda unexpected. The content of all images I checked:
root@0e903dfdb4c9:/app# cat /etc/localtime TZif2UTCTZif2UTC UTC0
Unfortunately, given this output there's not much I can do. Maybe you could use the built-in TZ environment variable parser and use the TZ parser if there is a TZ variable.
It's unfortunate: it basically means this crate is unusable in docker.
I just looked at how chrono solves it and it basically doesn't - it's and inherent problem that is typically solved by passing timezone for container manually IIUC. Which is a great surprize to me but manageable. anyway, kudos for crate! it's still better than chrono world IMO
Edit: I just had an idea, that aside from get_by_name
it would be really nice to have and interface to query by a standart abbreviation, like CET
So if you build in docker
get_timezone
will returnEtc/UTC
by default and would be wrong.For example I am in berlin tz and some of the machines I tried it are in other tz's. It always returns UTC, which is weird.
MRE:
if you create a simple binary and wrap it in docker this will not fail, but instead return
UTC
.