Add prefix methods for Week and Quarter Types. #164
Add prefix methods for Week and Quarter Types. #164Ianlmgoddard wants to merge 5 commits intomasterfrom
prefix methods for Week and Quarter Types. #164Conversation
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"
...
endWhich 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.
LilithHafner
left a comment
There was a problem hiding this comment.
Thanks for fixing these missing prefixes!
| prefix(::Type{Second}) = "S" | ||
| prefix(::Type{Millisecond}) = "ms" | ||
|
|
||
| # `Quarter` defined after Julia1.6. |
There was a problem hiding this comment.
| # `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.
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
MicrosecondorNanosecondbecause as far as I can tell,DateTimes are only defined up to millisecond precision (see JuliaLang/julia#31525). I wasn't sure if we wanted to displayDateTimeIntervals with greater precision than what is available forDateTimes.I also haven't added tests for
Quarterbecause 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.