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

Add datetime2unix(::ZonedDateTime) method #223

Open
CameronBieganek opened this issue Oct 4, 2019 · 1 comment
Open

Add datetime2unix(::ZonedDateTime) method #223

CameronBieganek opened this issue Oct 4, 2019 · 1 comment

Comments

@CameronBieganek
Copy link

Expected behavior:

julia> using Dates, TimeZones

julia> t = ZonedDateTime(2014, 7, 15, 14, 35, 46, tz"America/Chicago")
2014-07-15T14:35:46-05:00

julia> datetime2unix(zdt::ZonedDateTime) = datetime2unix(DateTime(astimezone(zdt, tz"UTC")))
datetime2unix (generic function with 2 methods)

julia> datetime2unix(t)
1.405452946e9
@giordano
Copy link
Contributor

The functionality is already there without defining custom functions:

julia> using TimeZones

julia> t = ZonedDateTime(2014, 7, 15, 14, 35, 46, tz"America/Chicago")
2014-07-15T14:35:46-05:00

julia> TimeZones.zdt2unix(t)
1.405452946e9

Note that PR #224 implements the interface that you'd like to have

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