time-rs / time

The most used Rust library for date and time handling.
https://time-rs.github.io
Apache License 2.0
1.06k stars 261 forks source link

Failing to acquire timezone information #591

Closed walksanatora closed 1 year ago

walksanatora commented 1 year ago

so when I do UtcOffset::current_local_offset() it errors out with IndeterminateOffset but yet if I look at timedatectl it looks llike it should work just fine

               Local time: Wed 2023-06-28 22:28:49 PDT
           Universal time: Thu 2023-06-29 05:28:49 UTC
                 RTC time: Wed 2023-06-28 22:28:49
                Time zone: America/Los_Angeles (PDT, -0700)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: yes

Warning: The system is configured to read the RTC time in the local time zone.
         This mode cannot be fully supported. It will create various problems
         with time zone changes and daylight saving time adjustments. The RTC
         time is never updated, it relies on external facilities to maintain it.
         If at all possible, use RTC in UTC by calling
         'timedatectl set-local-rtc 0'.

using time 0.3.22 in my project

jhpratt commented 1 year ago

What is your operating system?

walksanatora commented 1 year ago

Arch Linux running kernel 6.3.8-arch1-1

jhpratt commented 1 year ago

Is the process multi-threaded at the time of invocation?

walksanatora commented 1 year ago

it is within a async main from tokio so I would assume so (although it is only one thread since all futures are created then awaited)

jhpratt commented 1 year ago

If there are multiple threads running, which is more than likely when using tokio, then the call will fail on any Linux operating system (and most Unix-based operating systems). This is to guarantee that the program does not segfault.

walksanatora commented 1 year ago

is there any way to get the offset in a multi-threaded enviroment and then pass that into time for it to use

jhpratt commented 1 year ago

Any way to do that is unsound.