Skip to content

Add prefix methods for Week and Quarter Types. - #164

Open
Ianlmgoddard wants to merge 5 commits into
masterfrom
ig/prefixes
Open

Add prefix methods for Week and Quarter Types. #164
Ianlmgoddard wants to merge 5 commits into
masterfrom
ig/prefixes

Conversation

@Ianlmgoddard

Copy link
Copy Markdown

partially tackles #163

I haven't included prefixes for Microsecond or Nanosecond because 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 display DateTime Intervals with greater precision than what is available for DateTimes.

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.

@Ianlmgoddard
Ianlmgoddard requested a review from omus as a code owner April 20, 2021 14:45
@codecov

codecov Bot commented Apr 20, 2021

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.25%. Comparing base (f873f70) to head (abdb3f8).
⚠️ Report is 77 commits behind head on master.

Additional details and impacted files
@@            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              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Ianlmgoddard
Ianlmgoddard marked this pull request as draft April 20, 2021 14:54
@omus

omus commented Apr 21, 2021

Copy link
Copy Markdown
Collaborator

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.

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 @static before the if Julia can do the check at compile time allowing you to write unsupported syntax.

@Ianlmgoddard Ianlmgoddard changed the title Draft: Add prefix methods for Week and Quarter Types. Add prefix methods for Week and Quarter Types. Apr 21, 2021
@Ianlmgoddard
Ianlmgoddard marked this pull request as ready for review April 21, 2021 12:55

@LilithHafner LilithHafner left a comment

Copy link
Copy Markdown

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!

Comment thread src/description.jl
prefix(::Type{Second}) = "S"
prefix(::Type{Millisecond}) = "ms"

# `Quarter` defined after Julia1.6.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# `Quarter` defined after Julia1.6.
# `Quarter` defined in Julia v1.6.

Comment thread src/description.jl
Comment on lines +75 to +77

# 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")

Copy link
Copy Markdown

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,

Suggested change
# 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)

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

Successfully merging this pull request may close these issues.

3 participants