Live data from Hacker News

Ask HN: How is it that programmers can simply ignore leap seconds?

news.ycombinator.com

11–20 of 39 posts

Re: Ask HN: How is it that programmers can simply ignore leap seconds?

#11
> including applications that require a certain level of accuracy (e.g. processing pricing feeds from financial institutions)

Should leap seconds matter then? As long as you are synchronizing with the same source of truth as the financial institution's back-end, both clocks should tell the same time.

Re: Ask HN: How is it that programmers can simply ignore leap seconds?

#12
post #9

> If I create a date object of 1970-01-01T00:00:00 and repeatedly add 86400 seconds, should I not end up with a date/time that is no longer midnight? Of course and that’s why you shouldn’t do that. I don’t know about other languages, but if you want to advance a certain number of days, you don’t just add seconds. Any code review would pick that apart. You add (or subtract) date components, meaning you specify a day,…

If we were taking leap seconds into account, we should end up with a date/time that is not midnight.

Because it does always remain midnight, it shows we are all ignoring leap seconds.

Re: Ask HN: How is it that programmers can simply ignore leap seconds?

#13

> including applications that require a certain level of accuracy (e.g. processing pricing feeds from financial institutions) Should leap seconds matter then? As long as you are synchronizing with the same source of truth as the financial institution's back-end, both clocks should tell the same time.

What if we're trying to correlate prices from two different financial institutions? Maybe one uses smearing and one doesn't, who knows?

Re: Ask HN: How is it that programmers can simply ignore leap seconds?

#14
post #6

Computers usually report time in UTC but don't actually have leap seconds. Most computers are pretty bad at keeping time, and regularly sync to NTP servers for the current time. NTP servers generally have better time keeping hardware (or sync with better sources). When a leap second occurs, NTP servers will smear that second over 12 hours or so. Different NPT servers have different smear standards. During that smear,…

How can air-gapped computers keep time well?

Re: Ask HN: How is it that programmers can simply ignore leap seconds?

#15
POSIX requires that we ignore leap seconds. POSIX had no alternatives to this choice because the information needed to do time right was not, and still is not, readily available via an authoritative and robust mechanism. No international recommendation has ever required the creation nor funding of a mechanism better than "This one agency in Paris will use the post office to send out letters to your national government time service agency at least 8 weeks in advance of a leap."

Re: Ask HN: How is it that programmers can simply ignore leap seconds?

#16
post #6

Computers usually report time in UTC but don't actually have leap seconds. Most computers are pretty bad at keeping time, and regularly sync to NTP servers for the current time. NTP servers generally have better time keeping hardware (or sync with better sources). When a leap second occurs, NTP servers will smear that second over 12 hours or so. Different NPT servers have different smear standards. During that smear,…

How can air-gapped computers keep time well?

Use a GPS receiver, that will only get time reference and location from the GPS satellites, and not transmit anything. So you're still airgapped - see https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html for reference.

Re: Ask HN: How is it that programmers can simply ignore leap seconds?

#18
post #9

> If I create a date object of 1970-01-01T00:00:00 and repeatedly add 86400 seconds, should I not end up with a date/time that is no longer midnight? Of course and that’s why you shouldn’t do that. I don’t know about other languages, but if you want to advance a certain number of days, you don’t just add seconds. Any code review would pick that apart. You add (or subtract) date components, meaning you specify a day,…

> I don’t know about other languages...

Other programming languages apart from what? You never specified which language you're talking about.

Re: Ask HN: How is it that programmers can simply ignore leap seconds?

#19

Earlier quoted context omitted.

How can air-gapped computers keep time well?

Use a GPS receiver, that will only get time reference and location from the GPS satellites, and not transmit anything. So you're still airgapped - see https://gpsd.gitlab.io/gpsd/gpsd-time-service-howto.html for reference.

Is it really still airgapped if it accepts input from an outside system?

Re: Ask HN: How is it that programmers can simply ignore leap seconds?

#20
post #6

Computers usually report time in UTC but don't actually have leap seconds. Most computers are pretty bad at keeping time, and regularly sync to NTP servers for the current time. NTP servers generally have better time keeping hardware (or sync with better sources). When a leap second occurs, NTP servers will smear that second over 12 hours or so. Different NPT servers have different smear standards. During that smear,…

>When a leap second occurs, NTP servers will smear that second over 12 hours or so

Since when? I mean that literally, I only heard of this concept recently and didn't think it was a general standard, yet.

Post reply on HN