6 ms·
Let’s Stop the Unix Time Insanity
- nemetroid 13y agoMeh. Sounds to me like the author recently got burned by not knowing how Unix timestamps work.
- kbar13 13y agoI wouldn't assume anything, but it would be great if the blog post provided any kind of possible alternative. Right now it really just sounds like a misguided rant.
- Udo 13y agoThe idea is, instead of making the timestamp jump around (leading to both overlap and gaps), to make it a continuous linear counter. What's misguided about it? I realize we've been stuck with the Unix timestamp for so long it's become somewhat impossible for many to acknowledge the points where it breaks.
- deleted 13y ago[deleted]
- brianpgordon 13y agoWhat exactly is the call to action here? For kernel developers to change how time works, and probably break thousands of drivers and applications, based on a blog post?
- Udo 13y agoNo, willful misunderstanding aside, the idea is to provide a single continuous counter to apps that want it. If you look closely at most implementations, that's how many apps actually expect it to work.
- jonhohle 13y agoThere already is a continuous monotonic timer available in most operating systems, it just happens to be relative to some internal counter local to that system (and depending on virtualization layer doesn't always provide monotonic guarantees). This value can generally be translated into a fixed (and vice-versa), serialized timestamp for persistence.
- AndrewBissell 13y agoI think that's mainly a problem with apps using a wall clock time (e.g. System.currentTimeMillis() in Java) when what they really want is a monotonic clock based on a hardware counter of some kind (like System.nanoTime()). I'm not too familiar with what the clock situation is like for languages outside C/C++/Java.
- jasonlotito 13y ago> "a date like this:" > R(I, T, Z) = D > Those four final words... So yeah. Maybe I'm missing something obvious, or maybe the author is referring to another random set of 4 words?
- pedantpatrol 13y agoCongratulations! You have won the pedantic comment of the day award!
- AndrewBissell 13y agoI didn't really get what the author was referring to with "those final four words" either, this hardly seems like pedantry to me.
- bpaluzzi 13y agoI also don't think this is pedantry - it's one of the main parts of the article, and it currently doesn't make any sense.
- seagreen 13y agoThere's some great stuff about Unix time on this page: The Future of Leap Seconds http://www.ucolick.org/~sla/leapsecs/onlinebib.html http://www.ucolick.org/~sla/leapsecs/onlinebib.html See especially the 'Distinguishing the two different meanings for time' section. It makes a good distinction between time-of-day and time interval. Unix time measures the first.
- nl 13y agoI have no idea what the author is proposing, but I'm just posting to point out that it isn't the unix timestamp that is broken: it's dates in general. There is simply no algorithm that accounts for their behaviour all the time. The best you can do is have one that works most of the time, and then have a table of exceptions (which has to be locale based). For example, what date is 15330 days after February 30(!) 1712 in Sweden?[1] In November 1699, Sweden decided that, rather than adopting the Gregorian calendar outright, it would gradually approach it over a 40-year period. The plan was to skip all leap days in the period 1700 to 1740. Great.. except: In accordance with the plan, February 29 was omitted in 1700, but due to the Great Northern War no further reductions were made in the following years. Oops. Oh well: In January 1711, King Charles XII declared that Sweden would abandon the calendar, which was not in use by any other nation and had not achieved its objective, in favour of a return to the older Julian calendar. An extra day was added to February in the leap year of 1712, thus giving it a unique 30-day length But the Julian calendar sucks[2], so: In 1753, one year later than England and its colonies, Sweden introduced the Gregorian calendar, whereby the leap of 11 days was accomplished in one step, with February 17 being followed by March 1 Once you start doing date work you'll find these crazy cases all the time. Try and tell me today's date on Mount Athos... [1] https://en.wikipedia.org/wiki/Swedish_calendar#Solar_calendar https://en.wikipedia.org/wiki/Swedish_calendar#Solar_calenda... [2] https://en.wikipedia.org/wiki/Julian_calendar https://en.wikipedia.org/wiki/Julian_calendar [3] https://en.wikipedia.org/wiki/Mount_Athos#Date_and_time_reckoning https://en.wikipedia.org/wiki/Mount_Athos#Date_and_time_reck...
- haberman 13y agoWhat you are describing is not usually a problem in practice because: 1. Precise timekeeping for dates over 100 years old is not usually required (though perhaps you work in an area that is an exception?) 2. UNIX timestamps are independent of timezones and can be easily mapped to and from local time by standard, well-tested libraries. The Olson database maintains tables of local time zone information for modern time zones: http://en.wikipedia.org/wiki/Tz_database http://en.wikipedia.org/wiki/Tz_database Here is some discussion of Mount Athos, not sure if this was ever implemented or not though: http://comments.gmane.org/gmane.comp.time.tz/1610 http://comments.gmane.org/gmane.comp.time.tz/1610
- acqq 13y agoIt seems that the author thinks that Unix typically shows leap seconds to the application programmer? In fact, there aren't leap seconds there unless you intentionally turn that feature on. The seconds you get with the time() call will increment one by one. You will not have to care that leap second occurred. If you want to see leap seconds, then it is assumed that you know what you are doing. If you don't know the effects of that, please, please don't turn it on and don't write about how it's broken. If you want to learn more about leap seconds read: http://www.cl.cam.ac.uk/~mgk25/time/leap/ http://www.cl.cam.ac.uk/~mgk25/time/leap/
- haberman 13y agoThe author's proposal, for those who (understandably) did not glean it from the article, is that the UNIX timestamp becomes absolutely monotonic and, in the case of leap seconds, a day becomes 86,401 UNIX seconds long. Right now UNIX days are always exactly 86,400 seconds long, and time goes backwards a second when a leap second is added. > I know there is a lot of smugness going on in developer circles where people get high on posting comments such as “of course it is like this. it’s the way we’ve done it forever, it’s the only way.” What the author perceives as "smugness" is a reaction to criticism of the status quo without understanding and addressing the benefits of the status quo. I'm not preemptively dismissing the author's proposal, but you would have to overcome some fairly serious hurdles. Most notably, you would not be able to reliably construct dates in the future, because it is not generally known when leap seconds will be added. So it is unknowable what the "monotonic timestamp" for Jan 1, 2023 00:00:00 is, for example. I think a better answer to the problem is the leap second smear that Google has implemented: http://googleblog.blogspot.com/2011/09/time-technology-and-leaping-seconds.html http://googleblog.blogspot.com/2011/09/time-technology-and-l...
- Udo 13y agoOP here. I really wish this hadn't been submitted, but it's here so I might as well... > Most notably, you would not be able to reliably construct dates in the future You already need libraries for these functions. The only difference is that right now, those libraries have to calculate against a moving target instead of one that behaves predictably. I wrote this post a long time ago to suggest a strict(er) divide between computer timestamps and human timestamps, because Unix timestamps are in effect neither. There are countless apps that implicitly assume timestamps are linearly counted upwards. Most people would say those are bugs, but they'd only be right on superficial grounds. What most applications rightly want is a monotonic, predictable way to count the passing of time and to exchange that data with other apps. My idea was to introduce such a linear counter for apps that want it, not (as some people here obtusely suggested) replacing the Unix timestamp with this no matter the ecosystem breakage.
- haberman 13y ago> You already need libraries for these functions. I'm not sure if you caught my point. Library or no, it is impossible to construct future dates because it is unknown when leap seconds will be inserted until six months or so before it happens. Leap seconds are based on minute changes in the rotation of the earth, which are unpredictable. I added this to my comment later, but I think a better way to get a strictly monotonic timestamp is to smear the leap second: http://googleblog.blogspot.com/2011/09/time-technology-and-leaping-seconds.html http://googleblog.blogspot.com/2011/09/time-technology-and-l... > There are countless apps that implicitly assume timestamps are linearly counted upwards. There are also countless apps that implicitly assume that minutes are 60 seconds, hours are 3600 seconds, days are 86,400 seconds. Your scheme would break these apps.
- JulianMorrison 13y agoUse "bignum Planck units since the big bang". That is the ur-clock.
- azov 13y ago> Unix timestamps are thoroughly and unnecessarily broken. They should be a continuum. If you assume that system time is a continuum I have some bad news for you: system time is actually a user preference. Users can change it any moment to whatever they feel like, no time machine required. Given that, leap seconds are small potatoes. If you propose we change this and take away user's ability to set system time... well, there might be some merit in this from purely theoretical point of view, but in real world where batteries die, clocks get out of sync, and tons of software already rely on existing behavior - I don't think your proposal is likely to get very far :-) Now, if you want a continuum, it's already there: look up CLOCK_MONOTONIC.
- AndrewBissell 13y agoOne of the happiest moments for me when starting at my current job was the day I saw that all our servers were set to UTC as the default time zone. Leap seconds may cause some pain every 3 years or so, but a huge number of problems in system time accounting can be avoided by just keeping everything in UTC, and translating into a given timezone representation only at the highest possible level, just before displaying information to end users.
- dap 13y agoAt least on a single system, it's not that hard. You have to get over the fact that you can't compute accurate intervals by recording two human-datetime timestamps. Even aside from the myriad edge cases around date arithmetic, an administrator (or NTP) can always reset the clock between the endpoints of your interval, and your computation may be very wrong. If you want a human timestamp, use gettimeofday[0] and related functions. If you want something to compute actual elapsed seconds with, use high-resolution timestamps([2] and [3]). You just can't have both, and that's because of the way human dates work, not the way we represent them. [0] http://pubs.opengroup.org/onlinepubs/009695399/functions/gettimeofday.html http://pubs.opengroup.org/onlinepubs/009695399/functions/get... [1] http://www.lehman.cuny.edu/cgi-bin/man-cgi?gethrtime+3 http://www.lehman.cuny.edu/cgi-bin/man-cgi?gethrtime+3 [2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html http://pubs.opengroup.org/onlinepubs/9699919799/functions/cl...
- axus 13y ago"GPS Time" is UTC without the leap seconds. But it only goes back to 1980.
- peterwwillis 13y agoTime is relative, right? If anything we need a protocol to describe how the observer views time, not a rigid definition of expression of time as viewed by other people. Toward that end, unix time is totally usable, as long as you make the assumption that all unix time was created in a specific space and time. Then you just have to calculate what your observation of it is. That way, two bodies sitting next to each other may calculate the time that applies to them, and communicate by simply returning the time to the standard before comparing with other bodies. (Apparently this already exists; the Einstein synchronization procedure defines a method to establish universally (in the astronomic sense) temporal coordinates, which is in effect both location and time)
- haberman 13y agoI think you are missing the point that UNIX time moves backwards by a second whenever a leap second is added. It is discontinuous with respect to the actual passage of time.
- peterwwillis 13y agoUNIX time is simply an indicator of where you are in relation to the event of the epoch. Leap seconds are just our immature way of dealing with time dilation. You can always add or remove time as an observer to conform to whatever your view of time is in relation to that older fixed point.
- haberman 13y ago> UNIX time is simply an indicator of where you are in relation to the event of the epoch. That is true except in the case of leap seconds, in which case UNIX time is not monotonic or continuous. > Leap seconds are just our immature way of dealing with time dilation. Leap seconds have nothing to do with time dilation. TAI, on which UTC is based, is defined as the passage of proper time on Earth's geoid. This gives a stable base that is not influenced by the frame of the observer. UTC does not change based on where you observe it from. It is the same on Earth, in space, etc. regardless of your frame. None of this has anything to do with leap seconds. Leap seconds compensate for the fact that a mean solar day is slightly longer than 86,400 seconds, and can vary slightly due to irregularities in Earth's rotation. Leap seconds are added to keep UTC noon within a second of mean solar noon at the prime meridian. > You can always add or remove time as an observer to conform to whatever your view of time is in relation to that older fixed point. UTC is defined at the geoid, and everybody uses UTC seconds even though they are slightly shorter than seconds as observed by most people on Earth.
- btilly 13y agoIf you think that the problem is something called "Unix Time", then you do not actually understand the problem. The time used for "Unix Time" is actually UTC, which is a standard that is specified in international standards that predate Unix. It is specified in current international standards for everything from aviation to HTTP requests. If Unix tried to use something else, you'd generate massively more confusion for every Unix developer as they were having to figure out the current conversion to what is actually required for interacting with the rest of the world.
- haberman 13y ago> The time used for "Unix Time" is actually UTC Unix Time is not UTC; it is a linear representation that is surjective onto UTC. It is easy to map between the two but they are not the same. They are not even isomorphic or bijective because leap seconds have no unique representation in Unix Time. The Unix Time representation gives up full equivalence with UTC in order to provide some useful guarantees (days are always exactly 86,400 seconds long, midnight always satisfies x % 86,400 == 0, etc), but also creates other surprises (time can go backwards when a leap second occurs).
- BerislavLopac 13y agoThe obligatory link: http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time http://infiniteundo.com/post/25326999628/falsehoods-programm...