Crate geotime

source ·
Expand description

Geotime

Geotime provides a 128-bit signed integer timestamp compatible with Unix time_t and anchored at the Unix epoch.

use geotime::Geotime;

let dt = Geotime::from(0);
assert_eq!(dt.display_string("%Y-%m-%d"), "1970-01-01");

let dt = Geotime::from((i32::MAX as i128) * 1000);
assert_eq!(dt.display_string("%Y-%m-%d"), "2038-01-19");

let dt = Geotime::from((i64::MAX as i128) + 1);
assert_eq!(dt.display_string("%Y"), "299.87 M years from now");

let dt = Geotime::from(-(i64::MAX as i128) * 100);
assert_eq!(dt.display_string("%Y"), "29.99 B years ago");

A 128-bit timestamp allows us to represent times of events in astrophysical, geological, historical and present-day timescales to millisecond precision. We go down to milliseconds as a convenience for handling timestamps for recent events. In order to maintain a clean mapping to Unix timestamps, Geotime inherits whatever is going on with leap seconds. Timestamps can represent any date within +- 5e27 years of 1970.

Several serialization formats are provided that preserve lexical ordering of timestamps.

This project is rough at this point, and it is probably easy to trigger a panic. The plan is to gradually replace panics with errors, but it might be a while.

Structs

128-bit timestamp compatible with Unix time_t and anchored at 1970, the Unix epoch.
Hex encoding that can be lexically sorted.
Base 32 encoding that can be lexically sorted.
Base 64 encoding that can be lexically sorted.
Geohash-like encoding that can be lexically sorted.

Enums

Type Definitions