Skip to content

Commit

Permalink
Accessor and period names differ for Quarter
Browse files Browse the repository at this point in the history
  • Loading branch information
amsingh17 committed Sep 25, 2024
1 parent 1c414a8 commit 1729ae1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/accessors.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Dates: Year, Quarter, Month, Week, Day, Hour, Minute, Second, Millisecond, days, hour, minute, second, millisecond
using Dates: Year, Month, Week, Day, Hour, Minute, Second, Millisecond, days, hour, minute, second, millisecond

"""
timezone(::ZonedDateTime) -> TimeZone
Expand All @@ -9,14 +9,17 @@ timezone(zdt::ZonedDateTime) = zdt.timezone

Dates.days(zdt::ZonedDateTime) = days(DateTime(zdt))

for period in (:Year, :Quarter, :Month, :Week, :Day, :Hour, :Minute, :Second, :Millisecond)
for period in (:Year, :Month, :Week, :Day, :Hour, :Minute, :Second, :Millisecond)
accessor = Symbol(lowercase(string(period)))
@eval begin
Dates.$accessor(zdt::ZonedDateTime) = $accessor(DateTime(zdt))
Dates.$period(zdt::ZonedDateTime) = $period($accessor(zdt))
end
end

Dates.quarter(zdt::ZonedDateTime) = Dates.quarterofyear(DateTime(zdt))
Dates.Quarter(zdt::ZonedDateTime) = Dates.Quarter(quarterofyear(zdt))

Base.eps(::ZonedDateTime) = Millisecond(1)


Expand Down

0 comments on commit 1729ae1

Please sign in to comment.