-
-
Notifications
You must be signed in to change notification settings - Fork 24
Create UTC for Dates #36
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
base: master
Are you sure you want to change the base?
Conversation
IntroductionUsually technical systems generate absolute time stamps in UTC. Julia Nevertheless the leap seconds seem to have been so disturbing for the Rather the internal presentation of time in Base DateTime should be For calender time arithmetic Julia DateTime assumes that each day has Day segmented time typeWe are used to segment time for ourselves, into years, months, days, An updated Julia Base DateTime would use instead of the millisecond counter immutable UTCinstant
day2000::Int32 # nr of days since 2000-01-01
hus::Int32 # nr of 100 microsec on day
end To mark that this is a new time code, I suggest to use 2000-01-01 for With 32 bits for a (sub)seconds of day counter the smallest possible Date module interfaceConstructorsConstructors of course will have to made accept leap second time Types and functionsOtherwise the existing functions and operators in For interaction with software that cannot accept leap seconds, an Leap second tableA table of leap seconds is not needed for this proposal. CodingThe code for the SummaryWe propose to change the internal presentation of time in Julia Base Stephan B., Swedish Institute of Space Physics |
For reference other libraries without leap-second support.
Libraries with leap second support In some cases these support only inserting, not deleting. Also the situation is complicated in some cases for things like C where POSIX std says you must ignore the leap second, even though the language supports it. Time is really complex. |
I haven't quite followed all the discussion with this, so I won't comment on the specifics here, but more on the process. This is certainly a situation where all this functionality could be developed in a stand-alone package outside of Base and be made to work robustly + plenty of test coverage before needing to be considered to replace the Base implementation. The beauty of what is currently in Base is the simplicity, robustness, and test coverage, being some of the most well-tested code in Base. Anyway, carry on, just wanted to comment on the process more than proposal. |
That's an interesting proposal, thanks for writing it in detail. However, could you discuss the existing implementations? In particular, does any of them behave like you suggest? Why did they make these design choices (among others: old vs. recent, general-purpose vs. scientific...)? Do we have evidence that this works well in practice, is it annoying in some particular cases? Also I'm not sure I understand the consequences of this change in terms of time arithmetic. Currently the equality julia> DateTime(2017, 01, 02) - DateTime(2017, 01, 01)
86400000 milliseconds
julia> step(DateTime(2017, 01, 02):DateTime(2017, 01, 01))
1 day Do you suggest we get rid of this equality? (Note this is already what happens with months and days, so that's not necessarily a showstopper, but...) |
Not supporting leap seconds means not accepting any time stamps in leap seconds (like present Julia Dates). Support can mean:
This proposal would do 1), similar to POSIX. The real issues with leap seconds have been, that data got lost, ended up in the wrong time order, etc, when software didn't accept leap second time stamps, threw errors etc. But I never heard that calendar time arithmetic ignoring leap seconds caused any real problems, on the contrary, it is rather what people expect. Therefore I think that 1) is the most sensible approach. |
To write a separate package for this, I would need to build on functionality in Dates, otherwise it is a lot of work. However, Dates does not accept leap second time stamps. So catch22.... |
should perhaps become
to match the internal presentation (now: milliseconds, new: day, 100 us) But leap seconds should consistently get ignored in arithmetic:
though the physically elapsed time is 86401 sec. A point of the proposal is that a log file entry like "2016-12-31 23:59:60: 1,000,314.00 $ from account 123456789 to account 987654321" should not cause hickups, when it is processed using Julia Dates. |
In the package TimeZones.jl this is not true as a day can be equal to Hour(23), Hour(24), or Hour(25). I've been trying to revise some of the Base code where Day(1) == Hour(24) is assumed to always be true. See the documentation for examples of how calendrical arithmetic works with TimeZones.
This is the same problem that TimeZones faced. Currently the DateTime implementation doesn't have the functionality to handle TimeZones. I ended up solving this problem by introducing a new type: ZonedDateTime. I feel like the best approach for supporting leap seconds would be to add this functionality into a new package. Additionally, for accurate leap second support we would need to utilize the leap seconds data (ftp://ftp.iana.org/tz/tzdb-2017b/leapseconds) that IANA provides as part of tzdata. |
For this proposal a leap seconds table is not needed, because calendar arithmetic will ignore them. The user supplies leap second time stamps, and gets them back, that's all. The user can of course do calender arithmetic with his/her leap seconds time stamps, but the result will be the same as if the time stamp were just before the leap second. People who are interested in things on the second to subsecond level will not use the calender arithmetic functions/operators, but directly access the UTCinstant fields. |
I think the rhetoric in this Julep is a bit over the top:
The community is not "disturbed" by leap seconds, they're just a pain to deal with and if UT-based time is consistently used, they're not an issue. This was a design decision that was based on a lot of consideration and discussion with astronomers (among others), not some kind of panic response. Whether it was the right design decision or not is debatable but this verbiage is unnecessary and the attitude is not terribly constructive. There are two core issues with the current scheme:
This proposal may indeed be a good way to go. A mundane issue: this file should be named similarly to other Juleps in this repo and have an |
It's good that this proposal can represent leap seconds and dodges the need to compute with them. Leap second tables are a real pain. Functionality to get the real number of SI seconds between two @oxinabox - I don't think boost datetime has much in the way of leap second functionality. Leap seconds are mentioned in the documentation, but date time arithmetic ignores them (perhaps the reasoning was exactly the same as given in this julep, but it's not explained in the boost docs). |
A proposal to make Dates accept UTC leap seconds