TECHNOLOGY

Astropy leap-second time can exceed Python datetime representation

In this article
THE QUICK TAKE

The Time.to_datetime interface documents leap_second_strict with a default raising behavior and alternative warning or silent handling. Allowing conversion under another mode does not mean the target type gained a leap-second representation. The original time scale and format remain part of the scientific object. Choosing a string or numerical format also requires its own documented scale and precision interpretation. A successful datetime export is therefore not sufficient evidence that eve.

Astropy Time can represent a UTC leap second that Python’s ordinary datetime representation cannot encode directly. A scientific event exporter that silently forces the latter representation can lose a meaningful time distinction. The right response is an explicit conversion policy, not treating a valid astronomical time as corrupted input simply because a narrower output type rejects it.

The scientific interface

The Time.to_datetime interface documents leap_second_strict with a default raising behavior and alternative warning or silent handling. Allowing conversion under another mode does not mean the target type gained a leap-second representation. The original time scale and format remain part of the scientific object. Choosing a string or numerical format also requires its own documented scale and precision interpretation. A successful datetime export is therefore not sufficient evidence that every original instant and distinction survived unchanged.

Implementation details

Preserve the original Time representation and scale until the destination’s requirements are established. Keep strict rejection as a visible unsupported-conversion outcome when loss is unacceptable. If the application intentionally permits warning or silent conversion, record that policy and its information loss rather than advertising an exact round trip. Use a supported lossless scientific representation when needed, with explicit precision and scale metadata. Ensure downstream joins and ordering do not merge distinct source instants merely because the exported civil timestamp looks the same.

A constructed validation case

Construct known valid UTC instants immediately around a documented leap second, including the leap-second instant itself. Exercise the strict conversion and any deliberately permitted alternative modes separately. Compare source identity, ordering and recoverability after export rather than only checking that datetime objects were created. Acceptance requires visible representational limits and the chosen preservation policy. It does not require standard datetime to encode an unsupported instant or assume that a warning-suppressed conversion preserved all scientific timing information.

Numerical and data limits

Representable time is not proof of synchronized instruments or correct event detection. Those require independent evidence. This guide isolates an export boundary so a library’s narrower civil-time type does not silently redefine the scientific chronology used to train or evaluate an AI system.

Primary references

Astropy time scales and leap seconds; Astropy Time conversion API.

This is a proposed scientific-interface validation, not an executed Retrivium benchmark. Preserve the implementation version and unresolved outcomes; interface documentation does not establish the accuracy or performance of a scientific model.

Wrong time after restart: TLS errors and misleading log chronology; A GPU inference benchmark you can trust.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles