Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

17
  • So can we say that leap second, is a conversation note for formatting seconds to human readable date time? like time zone? I can use standard libraries, but my question is more about "What is happening?" Commented Oct 14, 2023 at 16:44
  • To be clear, on this post: stackoverflow.com/questions/6161776/…, there is comment as "Leap seconds were introduced in 1972. So there is none between 1601 and 1970 and thus irrelevant in this conversion." and from what I understand from your answer, it is not right to think about leap second, while converting between UNIXTIME and FILETIME as the both are just monotonic counters after an specific time in UTC time system. Correct? Commented Oct 14, 2023 at 16:53
  • 4
    "To be clear: "UNIX time" is simply the number of seconds passed since a specific event (0:00 on the first of January 1970). There's no ambiguity there anywhere." -- well, except that there is, namely the thing about which exact moment of time 1970-01-01 00:00 is. Leap seconds can make days differ in length (and we're not talking about daylight saving here), but POSIX defines the "seconds since epoch" as counting exactly 86400 seconds per day. Commented Oct 14, 2023 at 17:47
  • 4
    @MarcusMüller, note that it's not actually defined as redefining the reference point. It's defined as a number you get when you do a particular calculation on the broken-down UTC date and time. A calculation that is obvious, appears correct, and produces a practical and useful result, but happens to close its eyes and go la-la-la at obscure impractical thingies like "leap seconds". (The reference point getting "moved" is just an emergent result of taking the "seconds since the epoch" literally and applying that to the definition.) Commented Oct 14, 2023 at 18:28
  • 1
    @Okoba You can prove to yourself that Unix time doesn't take leap seconds into account by noticing that the first second of next year can be determined without taking them into consideration. Running TZ=UTC date --date @$(perl -e '$seconds += 86400 * ($_ % 4 ? 365 : 366) for 1970 .. 2023; print $seconds') '+%F %T %z (%Z)' produces 2024-01-01 00:00:00 +0000 (UTC) on Linux, as does running TZ=UTC date -r $(perl -e '$seconds += 86400 * ($_ % 4 ? 365 : 366) for 1970 .. 2023; print $seconds') '+%F %T %z (%Z)' on BSD (including MacOS). Commented Oct 15, 2023 at 22:38