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

How to get UTC Offset as integer #353

Open
bryaan opened this issue Jul 23, 2021 · 2 comments
Open

How to get UTC Offset as integer #353

bryaan opened this issue Jul 23, 2021 · 2 comments

Comments

@bryaan
Copy link

bryaan commented Jul 23, 2021

How can I get the current UTC offset from tz"America/New_York" ?

@omus
Copy link
Member

omus commented Jul 23, 2021

You can use access the offset of a specific ZonedDateTime via:

julia> using TimeZones

julia> now(tz"America/New_York").zone.offset
UTC-5/+1

julia> string(ans)
"-04:00"

If this is something you're just wanting to view for yourself you can do:

julia> show_next_transition(tz"America/New_York")
Transition Date:   2021-11-07
Local Time Change: 02:00  01:00 (Backward)
Offset Change:     UTC-5/+1  UTC-5/+0
Transition From:   2021-11-07T01:59:59.999-04:00 (EDT)
Transition To:     2021-11-07T01:00:00.000-05:00 (EST)

Which shows the current offset in "Offset Change" as well as a other information.

@bryaan
Copy link
Author

bryaan commented Jul 25, 2021

@omus Thank you! Can we add an int(timezoneawaretime) to make integer conversion easier?

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