Skip to content

time: document that package does not support leap seconds #15247

@phayes

Description

@phayes

The time package does not support leap seconds. This is further explored in these two issues:
#15190
#8728

While it looks like this won't be fixed until Go 2.0, we can at least document the current behavior. Specifically the following things should be documented:

  1. The definition of a "second". Specifically, it should be clarified that go uses the "POSIX-second". A POSIX-second is equal to one standard second in all cases except when a POSIX-second is followed by a leap-second, in which case the POSIX-second is equal to two standard seconds, and the leap-second is skipped. This means that when calculating the Duration between two dates as a number of seconds, the unit being calculated is POSIX-seconds. To convert to standard seconds, add the number of leap seconds that occurred between the two dates in question.
  2. The time package does not support parsing datetimes that contain a leapsecond. For example, the package will not parse 2005-12-31T23:59:60Z.
  3. The behavior of time.Sleep is unaffected and uses standard seconds in all cases, since it uses a monotonic clock provided by the runtime package. (As far as I can figure it, this needs to be confirmed)
  4. The behavior of the above items on non-POSIX systems (like windows)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions