pub fn subsecond_precision(timestamp_literal: &str) -> u8Expand description
Extract subsecond precision from an ISO timestamp literal
Given a timestamp like ‘2023-01-01 12:13:14.123456+00:00’, returns the precision (0, 3, or 6) based on the number of subsecond digits.
§Arguments
timestamp_literal- An ISO-8601 timestamp string
§Returns
The precision: 0 (no subseconds), 3 (milliseconds), or 6 (microseconds)
§Example
use polyglot_sql::time::subsecond_precision;
assert_eq!(subsecond_precision("2023-01-01 12:13:14"), 0);
assert_eq!(subsecond_precision("2023-01-01 12:13:14.123"), 3);
assert_eq!(subsecond_precision("2023-01-01 12:13:14.123456"), 6);