6 ms·
> we want to convert them to an integer presenting the number of seconds since the Unix epoch. The Unix epoch is January 1st 1970. UNIX time ignores leap secon
by paulddraper 3y ago
> we want to convert them to an integer presenting the number of seconds since the Unix epoch. The Unix epoch is January 1st 1970.
UNIX time ignores leap seconds.
I.e. it's the number of seconds ignoring leap seconds since 1970.
- MobiusHorizons 3y agoSure, but he’s not parsing Unix timestamps. He’s parsing time in the format %Y%m%d%H%M%S, which would have leap seconds on most systems
- paulddraper 3y agoHe's parsing them into UNIX timestamps. And apparently these strings don't have second 60. Works for me.
- dataflow 3y ago> UNIX time ignores leap seconds. Side note but I always found this phrasing to be incredibly confusing (hence the need for the "i.e."...); it's the exact opposite of what I would think it means to "ignore" leap seconds. Ignoring something means you don't change your behavior when that something happens. But when leap seconds happen, the epoch timestamp halts its counting. That's not ignoring leap seconds -- that's actively countering the leap seconds!
- paulddraper 3y agoIgnores = does nothing Normally, UNIX time goes up by one each second. Unless, it's a leap second, in which case UNIX time does nothing.
- dataflow 3y agoHalting the advancement that would've ordinarily happened is not "ignoring it", it's doing something to actively counter it. That "something" ends up canceling the previous trajectory to evaluate to "nothing", but that doesn't happen through ignorance - it required a countering action. Example: You're driving your car when pedestrians appear in front of you. What does "ignoring" them constitute? Stopping the car, or running into them at the previous speed?
- agons 3y agoI'd say that the people counting leap seconds are the ones "doing something". At the point they needed to be inserted, Unix systems carry on counting seconds as units of time as they pass, "ignoring" the need to add 1 for the purposes of accounting.
- zokier 3y ago> At the point they needed to be inserted, Unix systems carry on counting seconds as units of time as they pass unix systems essentially will roll back clocks during leap seconds. here is handy dandy table as an example: Time tv_sec tv_usec 2015-06-30T23:59:58.9Z 1435708798 900000 2015-06-30T23:59:59.0Z 1435708799 0 2015-06-30T23:59:59.1Z 1435708799 100000 ... ... ... 2015-06-30T23:59:59.9Z 1435708799 900000 2015-06-30T23:59:60.0Z 1435708799 0 2015-06-30T23:59:60.1Z 1435708799 100000 ... ... ... 2015-06-30T23:59:60.9Z 1435708799 900000 2015-07-01T00:00:00.0Z 1435708800 0 2015-07-01T00:00:00.1Z 1435708800 100000 ... ... ... I don't know about you but I wouldn't call that "counting seconds as units of time as they pass"
- paulddraper 3y agoI suppose you can envision UNIX clock with "inertia"/Newton's second law. But when I count people passing me, I press my clicker each time to count them. Except once in a while I don't do anything, i.e. ignore them.
- catiopatio 3y agoNot doing anything is a decision to depart from your standard behavior. It’s not “ignoring”.
- michaelt 3y agoIf a system considers 2016-12-31 23:50 UTC and 2017-01-01 00:10 UTC to be 20 minutes apart because it is ignorant of leapseconds - is that ignorance "active"?
- Groxx 3y agoyeah - "ignoring" to me means "is ignorant of" means "one second passing means increasing the time by one second". You do by far the most obvious thing when time passes, and you ignore the complexities of reality to continue being maximally obvious. Doing anything else means handling them by adding custom behavior.
- Dylan16807 3y agoThe computer that uses timestamps usually recognizes leap seconds. But that doesn't mean the timestamp itself recognizes them. You can make a pretty good argument that "every day is 86400 seconds" is ignoring leap seconds. And that's what "Unix time" does. Though you can also make a good argument that "seconds since 1970, no idea what a 'day' is" ignores leap seconds.
- zokier 3y agoYes, that means that :60 should parse into same value as :59. My reading of the code is that now it might end up in the `return false` branch instead, although I'm not exactly sure how the limits thing is used here
- fanf2 3y agoThat is not how POSIX defines seconds since the epoch. It says that :60 is the same as :00 of the following minute. https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_16 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1...