pub fn parse_time(payload: &str) -> StringExpand description
Rewrite RFC 3339 timestamps inside a serialized JSON payload to
"yyyy-MM-dd HH:mm:ss.SSS", mirroring the Go SDK’s parseTime.
Timestamps without fractional seconds are padded to .000, fractional
digits beyond three are truncated, and the time zone offset is dropped.
use thinkingdata_core::utils::parse_time;
let payload = r##"{"#time":"2024-01-02T03:04:05.123456+08:00"}"##;
assert!(parse_time(payload).contains(r#""2024-01-02 03:04:05.123""#));
let no_fraction = r##"{"#time":"2024-01-02T03:04:05Z"}"##;
assert!(parse_time(no_fraction).contains(r#""2024-01-02 03:04:05.000""#));