Module timestamp

Source
Expand description

Timestamp handling utilities

Structs§

TimestampCache
Optimized cache-friendly timestamp cache for frequent conversions Used for caching and reusing conversion results for common timestamps

Enums§

TimestampFormat
Timestamp format used by different exchanges

Functions§

days_since_epoch
Calculate days since Unix epoch (1970-01-01) with leap year handling
exchange_time_to_nanos
Convert exchange timestamp to nanoseconds based on its format This is a performance-critical function used in hot paths
is_leap_year
Check if a year is a leap year
iso8601_to_nanos
Parse ISO8601 String to nanoseconds since epoch using optimized parsing This version is significantly faster than the previous implementation Handles format like “2023-01-01T12:00:00Z” or “2023-01-01T12:00:00.123Z”
ms_to_nanos
Optimized version that converts timestamp to nanoseconds without checking format Used when format is known at compile time
parse_u64_from_bytes
Parse a fixed-width byte slice to u64, optimized for parsing ISO8601 components
seconds_to_nanos
Optimized version that converts seconds to nanoseconds
time_smartstring_to_seconds
Convert timestamp String like “HH:MM:SS” to seconds since midnight Optimized for minimal allocations and faster parsing
us_to_nanos
Optimized version that converts microseconds to nanoseconds