Skip to main content

normalize_ts_to_ms

Function normalize_ts_to_ms 

Source
pub fn normalize_ts_to_ms(ts: i64) -> i64
Expand description

Normalize a raw exchange timestamp to UTC milliseconds.

Heuristic based on digit count of the absolute value:

  • ≤ 10 digits (≤ 9_999_999_999) → seconds → × 1_000
  • 13 digits (10_000_000_000 to 9_999_999_999_999) → milliseconds → identity
  • 16 digits → microseconds → ÷ 1_000
  • ≥ 19 digits → nanoseconds → ÷ 1_000_000
  • Zero or negative below seconds range → 0