Skip to main content

parse_broker_ts

Function parse_broker_ts 

Source
pub fn parse_broker_ts(raw: Option<&str>) -> Option<UnixNanos>
Expand description

Parses a time string of the BCS API into nanoseconds since the Unix epoch.

Reads RFC 3339 (2026-10-19T10:00:00.123+03:00) and the form 2026-10-19T10:00:00.123Z. None when the input is None or in neither form. A time with no zone is not accepted, because its zone would be a guess.

§Examples

use brokapi_bcs::map::parse_broker_ts;

let t = parse_broker_ts(Some("2026-10-19T10:00:00.500Z")).expect("a valid time");
assert_eq!(t.as_nanos() % 1_000_000_000, 500_000_000);
assert!(parse_broker_ts(Some("yesterday")).is_none());
assert!(parse_broker_ts(None).is_none());