Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get the time zone from zoned_time with time zone "" #366

Open
eitsupi opened this issue Feb 29, 2024 · 4 comments
Open

Can't get the time zone from zoned_time with time zone "" #366

eitsupi opened this issue Feb 29, 2024 · 4 comments

Comments

@eitsupi
Copy link

eitsupi commented Feb 29, 2024

library(clock)
x <- zoned_time_now("")
x
#> <zoned_time<nanosecond><Etc/UTC (current)>[1]>
#> [1] "2024-02-29T10:42:02.461454657+00:00"
zoned_time_zone(x)
#> [1] ""

Created on 2024-02-29 with reprex v2.0.2

Related to #365, I want to get the time zone string but it returns an empty string "".
Is this the intended behavior?
If intended, could you please export the zone_current function?

@DavisVaughan
Copy link
Member

Does polars not have the concept of "local time zone"?

@eitsupi
Copy link
Author

eitsupi commented Feb 29, 2024

Does polars not have the concept of "local time zone"?

I think Apache Arrow only has timestamp types with / without time zone.
https://github.com/apache/arrow/blob/d3ae78855c40c55c23b07e04ffe769f52d1aec30/format/Schema.fbs#L276-L283

@DavisVaughan
Copy link
Member

I looked over the implementation of zone_current() again and it is very very likely that it will return Sys.timezone() unless:

  • The TZ env var is set to something else, which is rare
  • Sys.timezone() returns a non-character, in which case it returns "UTC", which would be even rarer

So I think you can safely use Sys.timezone() for now

@eitsupi
Copy link
Author

eitsupi commented Feb 29, 2024

Thank you for looking into the details!
I will do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants