-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 Dates module to Base #7654
Add Dates module to Base #7654
Conversation
The docs and tests for this are amazing! Very impressive. |
As was brought up here, there's currently an inconsistency in how inputs are checked/validated when building Dates/DateTimes by parts. Currently, only months are checked that they are in the range 1..12, otherwise an error is thrown. For other parts (day, hour, minute, etc.), values outside a valid range serve to "roll" back or forward the date. So I'd love to get some feedback on what people think we should do here. Here are the options/arguments: Validate that all inputs are sane:
Option 2, don't validate any input, but extend the "roll" forward/backward behavior to months:
I feel I could go either way on this, but honestly, I don't think it's a very common case that you accidentally pass an out of range value and it comes back to bite you if it was rolled forward. I think with clear documentation, this could even be a feature in terms of certain algorithms or calculations and as noted above in working with certain database values. I'd love to hear everybody's thoughts though. |
Tough call. I think I would prefer to get the checks by default, with an option to disable them to get the rollback behavior when needed. It would be interesting to know whether raising an error with incorrect dates creates issues in certain cases in Java 8 and Python. |
Thanks for the input @nalimilan. I spent a good chunk of time coding up both scenarios yesterday and comparing performance, etc and I think it'll be best to go with the checks by default. It really doesn't add any hit to Dates, but DateTimes are just under 2x slower, which isn't too bad in my book for having consistency. I'm still open to other ideas if anyone has them, but I think we'll go with the checks by default for now. |
…s a few math operations
… foundation for better range support
…ethods. Also give better typed results with vectorized arithmetic operations
…t on their machine)
…moved to types.jl
….jl to be used in validating inputs
…ded function is not correct
…rect by using a single inner 'len' function that is used in length(), steprem(), and in(). Also added lots and lots of tests to try to cover all combinations of Date/DateTime, different Period steps, with positive and negative step values.
Code for ranges is such a beast. I'm probably a little overboard on the range tests now, but there are so many cases to check for. On the bright side, the date range code is now way cleaner (and more correct!). |
I'd like to propose this go into 0.4. At this point, the code has been through several iterations and most parts seem to have settled as a good API. I'd still appreciate getting a few heads together for a hangout/irc code review to sanity check everything, but I think getting it into people's hands at this point will help shake anything else out. Any volunteers for a hangout? Fun fact: the current breakdown of lines is: 1000 lines of code, 750 lines of docs, and 2500 lines of tests. |
+1 for this in 0.4. |
Guys, I just realized that today is August 16, which is a date, and this is a PR all about dates, so what a better reason to merge! The coincidence is incredible! |
Can't fault that kind of argument. |
I say merge it. I'm excited. Who gets to push the button? |
I got to push the button :-) |
LOL |
Hilarious. |
Or maybe I should have waited for @quinnj, I feel kind of bad. |
Eh, it's done now. If everything breaks it's your fault :-P I'm excitedly building the new master with built-in Dates support. Even though I've tried the branch before, somehow it feels different once it's actually merged. Like now it's "real". |
Woo hoo! I'll get on to porting my packages. Maintaining backwards compatibility will be interesting. There are some packages that depend on nolta/Calendar.jl. Some depend on quinj/Datetime.jl. @quinnj : Will you maintain Dates.jl with a compatible API for the 0.3 - 0.4 cycle? That might actualy be the best option for packages. Packages can then conditionally import Dates.jl, and subsequently work with a single API. It'll be a shame if packages become "0.4 only" due to using Base.Dates. |
How long is the dates test supposed to take? On my RHEL5 system it appears to be hanging |
Hm nevermind, either I'm impatient or it's intermittent. The date tests do take about a minute on Linux, it would be good to move them earlier in the list for the sake of parallel testing. |
Awesome. Just awesome. No worries on the merge @ivarne; I probably should have realized I would be driving for a good portion of the evening. Just happy it's in! @aviks, yeah, I can keep the Dates.jl package going for the 0.4 cycle, if packages want to use it as a stepping stone for 0.3 support. The bigger issue is getting packages over from Datetime.jl; while the API isn't hugely different, if they were relying heavily on timezone support, that's the main difference now with functionality split out into TimeZones.jl. @tkelman, there has been a little weirdness with travis lately, see @IainNZ's comments on #7787. I don't think I've ever seen anything locally though. I could probably trim down some of the tests as some of the tests take an input for how many iterations to run. I agree though that it would probably be good to move it earlier in the testing process. |
Not talking about Travis, rather locally. But on both I see some warnings about imported bindings for |
That's a good point. I wonder why I've never seen those before in all my testing? |
This is a nonbreaking merge right? |
Non-breaking was definitely the plan, unless we see some kind of weirdness with Base.Dates vs. Dates.jl out there. That's an interesting question actually, if I have the Dates.jl package installed and run Good call @IainNZ on the news.md, I'll do a little writeup. |
We'll find out if its breaking tomorrow morning, I suppose :) |
Hmmm.......why don't |
Dates test is definitely freezing occasionally on Win32 and 64-bit Ubuntu 14.04. |
Ok, I think I fixed the exports in sysimg.jl with this commit. Thanks for the report @tkelman, it would be great if you could narrow down which test file (in the |
@quinnj as best as I can tell with some Lines 34 to 45 in 4ba73cf
Another Win32 freeze happened somewhere in Lines 148 to 172 in 4ba73cf
These are intermittent and might be Julia's fault instead of anything specific to dates, they look a lot like #7942 which previously wasn't happening on Win32. |
Yeah, I think I've got that one figured out, but I'm running into a weird no method bug with similar further down in the tests. |
I think there should be an entry both in |
Only problem this seems to have maybe triggered: JuliaFinMetriX/TimeData.jl#1 |
Ok @tkelman, I fixed the 32-bit issues I've seen locally in 9f81a60 and e3e86b5. Note that the range tests using |
Fixes #3524.
Cross-reference: #5328, quinnj/Dates.jl#6, quinnj/Datetime.jl#12.
Successor to #7285 PR because of a weird github merge bug.
There were a few tweaks to the code from the original PR, nothing major. Additional tests and docs! I'd especially appreciate feedback on the content and structure of the docs.