Skip to content

Commit

Permalink
Additional tests for zdt2unix/unix2zdt (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
spurll authored and omus committed Nov 3, 2017
1 parent 14ece98 commit 73f43ca
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,20 @@ end
@test TimeZones.zdt2unix(Float32, ZonedDateTime(1970, 1, 1, 0, 0, 0, 750, utc)) == 0.75
@test TimeZones.zdt2unix(Int64, ZonedDateTime(1970, 1, 1, 0, 0, 0, 750, utc)) == 0
@test TimeZones.zdt2unix(Int32, ZonedDateTime(1970, 1, 1, 0, 0, 0, 750, utc)) == 0

# round-trip
zdt = ZonedDateTime(2010, 1, 2, 3, 4, 5, utc)
round_trip = TimeZones.unix2zdt(TimeZones.zdt2unix(Int64, zdt))
@test round_trip == zdt

# millisecond loss
zdt = ZonedDateTime(2010, 1, 2, 3, 4, 5, 999, utc)
round_trip = TimeZones.unix2zdt(TimeZones.zdt2unix(Int64, zdt))
@test round_trip != zdt
@test round_trip == floor(zdt, Dates.Second(1))

# timezone loss
zdt = ZonedDateTime(2010, 1, 2, 3, 4, 5, warsaw)
round_trip = TimeZones.unix2zdt(TimeZones.zdt2unix(Int64, zdt))
@test round_trip == zdt
@test !isequal(round_trip, zdt)

0 comments on commit 73f43ca

Please sign in to comment.