-
-
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
Allow date periods to be represented by Floats #9393
Comments
It seems to me like allowing fractional types here would be ok. @quinnj? |
The simplest route would be to make all periods ≤ week an immutable wrapper around Instead of having Adding a (float) |
If that level of precision was actually required, could some sort of implementation of a |
I feel like this is a really good candidate for have a parametric type since different people have such different needs. |
What is the use case for needing more than 2^53 of a time period in (2^53 ms is about 280,000 years. Is there a real situation in which you would be measuring, say, 1,000,000 years in milliseconds and need millisecond precision? I'm skeptical. Even so, you could use the |
The quick answer is that it was simpler to implement everything in I think the proposal to have I'll have time to play around with implementing this starting next week. |
I started playing around with this myself, and have been running into just one major issue when running all of the date test files. I can't figure |
Won't |
Having Should My fork here if it's easier to look at with the slightly adjusted TimePeriod types. |
Yes, they should truncate (not round). |
…apped around Int Week, Day, Hour, Minute, Second are wrapped around Real to allow for conversion between Millisecond remained wrapped around Int Ref Issue JuliaLang#9393
…apped around Int Week, Day, Hour, Minute, Second are wrapped around Real to allow for conversion between Millisecond remained wrapped around Int Ref Issue JuliaLang#9393
Honestly, I wonder if we really need the I say that because we could just have immutable Date
value::Int64
end
immutable DateTime
value::Int64
end and then not have to worry about using a |
…apped around Int Week, Day, Hour, Minute, Second are wrapped around Real to allow for conversion between Millisecond remained wrapped around Int Ref Issue JuliaLang#9393
fwiw there is an 'always' in "it is bad practice to use floats with dates and/or times." |
This has been open for quite a while now with no progression or discussion. I'm firmly in the camp of keeping everything integer-based, unless someone out there is really willing to go all out and do a full re-implementation based on Floats. I still believe, though, that one of the strengths of our Dates implementation is the amount of functionality and performance we achieve with such small, readable code. Happy to re-open if people feel strongly, but I think we close as decided. |
Dates currently forces the periods to be integer types which does not allow for functions like 1 day / 2 = 0.5 days or 12 hours even. Is there a way to base date types on the millisecond and the specific type (day,hour,etc) is just the appropriate conversion?
I know this would only work up until the "week" type, but it would allow for better arithmetic of dates types below the week level.
The text was updated successfully, but these errors were encountered: