Skip to content
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 rounding operations for ZonedDateTimes #29

Merged
merged 4 commits into from
Jul 21, 2016

Conversation

spurll
Copy link
Contributor

@spurll spurll commented Jul 4, 2016

Dependent on PR #17037 in Base Julia.

Checks will fail and need to be rerun once that PR is merged into Base.

@omus omus self-assigned this Jul 4, 2016
straightforward fashion.

Rounding is not an entirely "safe" operation for `ZonedDateTime`s, as in some cases
historical transitions for some time zones (`Asia/Colombo, for example) occur at midnight.
Copy link
Member

Choose a reason for hiding this comment

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

Missing ending backtick

Documentation changes were made based on PR feedback.
`ceil(ZonedDateTime(1996, 10, 26, 0, 35, TimeZone("Asia/Colombo")), Dates.Day)`
no longer results in an AmbiguousTimeError.
Added test cases for rounding to nearest week.
@omus
Copy link
Member

omus commented Jul 11, 2016

Rounding for Date/DateTime have been merged into base (JuliaLang/julia#17037). Looking into this PR again.

@omus
Copy link
Member

omus commented Jul 11, 2016

@spurll Julia 0.4 is failing since the rounding functions don't exist in base for that version. Probably the best approach here is to conditionally include the rounding functionality based upon the Julia version. You can do this by determining the commit which includes the rounding functionality in Base then using Compat's version.sh script to generate a version number literal.

@codecov-io
Copy link

codecov-io commented Jul 11, 2016

Current coverage is 89.82%

Merging #29 into master will decrease coverage by 0.37%

@@             master        #29   diff @@
==========================================
  Files            15         16     +1   
  Lines           673        678     +5   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            607        609     +2   
- Misses           66         69     +3   
  Partials          0          0          

Powered by Codecov. Last updated by 4cb5192...601c216

@omus
Copy link
Member

omus commented Jul 12, 2016

Appveyor failure on 0.5 is due to JuliaPackaging/WinRPM.jl#78

and should generally behave as expected. When `VariableTimeZone` transitions are involved,
however, unexpected behaviour may be encountered.

Instead of performing rounding operations on the `ZonedDateTime`'s internal UTC `DateTime`,
Copy link
Member

Choose a reason for hiding this comment

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

"internal UTC representation" or "internal UTC DateTime representation"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. ZonedDateTimes do have an internal DateTime that's in UTC of course, but if you think this is more clear that's your call.

Copy link
Member

Choose a reason for hiding this comment

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

I'd rather not reference how the internals of ZonedDateTime work at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's totally fair. I considered that when I was writing it, but I figured that some people who do know about the internals might wonder why we're not just using UTC, so I wanted to put this explanation somewhere.

Do you think this should be moved to a comment in the code, perhaps? Or just removed entirely?

Copy link
Member

Choose a reason for hiding this comment

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

I think you can mention the two strategies of either performing rounding in the UTC time zone or the local time zone but I wouldn't mention which is used internally

Minor tweaks to documentation as requested in PR comments.
Replaced calls to `TimeZone` with calls to `resolve` in test cases.
@omus
Copy link
Member

omus commented Jul 12, 2016

@spurll PR looks good. I'm ready to approve but I'm going to wait until JuliaPackaging/WinRPM.jl#78 is addressed.

@omus omus merged commit b7bca23 into JuliaTime:master Jul 21, 2016
@omus omus deleted the date-rounding branch July 21, 2016 14:23
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