parse_ims_timestamp

Function parse_ims_timestamp 

Source
pub fn parse_ims_timestamp(raw: &str) -> Option<NaiveDateTime>
Expand description

Parse an IMS created timestamp into a comparable value.

CSM returns created in more than one shape, so try chrono::NaiveDateTime first, then chrono::DateTime<Local>, normalising a zoned timestamp to local naive time. Returns None when neither parses.

A zoned timestamp is converted into this process’s local timezone, so the same input yields a different naive value on hosts in different zones. Callers that compare across the client/server boundary (the CLI renderer vs. the server’s date filter) agree on which strings parse, not necessarily on the wall-clock value of a zoned one.

Lives here rather than in either binary because the server filters on this value (service::image::get_images) while the CLI renders it (output::image). If the two disagreed on what parses, a row could display a creation date that the filter silently drops.

use manta_shared::common::parse_ims_timestamp;

// Naive, offset, and the `Z`/fractional-second shapes IMS emits.
assert!(parse_ims_timestamp("2026-06-04T12:30:00").is_some());
assert!(parse_ims_timestamp("2026-06-04T12:30:00+00:00").is_some());
assert!(parse_ims_timestamp("2026-06-04T12:30:00Z").is_some());
assert!(parse_ims_timestamp("2026-06-04T12:30:00.643891Z").is_some());
assert!(parse_ims_timestamp("not-a-real-date").is_none());