-
Notifications
You must be signed in to change notification settings - Fork 18
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 prefix
methods for Week
and Quarter
Types.
#164
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #164 +/- ##
==========================================
+ Coverage 81.09% 81.25% +0.15%
==========================================
Files 11 11
Lines 603 608 +5
==========================================
+ Hits 489 494 +5
Misses 114 114
Continue to review full report at Codecov.
|
Use conditional blocks like: if VERSION >= v"1.6"
...
end Which allows you to only run code if the Julia version is above or equal to 1.6.0. It shouldn't matter here but if you use |
prefix
methods for Week
and Quarter
Types. prefix
methods for Week
and Quarter
Types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing these missing prefixes!
prefix(::Type{Day}) = "D" | ||
prefix(::Type{Hour}) = "H" | ||
prefix(::Type{Minute}) = "M" | ||
prefix(::Type{Second}) = "S" | ||
prefix(::Type{Millisecond}) = "ms" | ||
|
||
# `Quarter` defined after Julia1.6. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# `Quarter` defined after Julia1.6. | |
# `Quarter` defined in Julia v1.6. |
|
||
# informative error if no prefix is defined for the given type. | ||
prefix(T::Type{<:Period}) = error("A prefix for period $T has not yet been defined") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we'd like it to "just work" instead of throwing,
# informative error if no prefix is defined for the given type. | |
prefix(T::Type{<:Period}) = error("A prefix for period $T has not yet been defined") | |
# Full name if no prefix is defined. | |
prefix(T::Type{<:Period}) = string(T) |
partially tackles #163
I haven't included prefixes for
Microsecond
orNanosecond
because as far as I can tell,DateTime
s are only defined up to millisecond precision (see JuliaLang/julia#31525). I wasn't sure if we wanted to displayDateTime
Intervals with greater precision than what is available forDateTime
s.I also haven't added tests for
Quarter
because it's not clear to me how to get around the fact that this type was only introduced in Julia v1.6. Any advice there would be appreciated.