Skip to main content

parse_log_timestamp

Function parse_log_timestamp 

Source
pub fn parse_log_timestamp(s: &str) -> Result<DateTime<Utc>, TimestampError>
Expand description

Parses a locale-dependent timestamp from an MTGA log entry header.

Tries all 11 known locale-dependent formats in sequence until one succeeds. The input should be the timestamp portion extracted from a log entry header line.

§Timezone caveat

MTGA log entry headers contain local wall-clock time with no timezone information. The returned DateTime<Utc> is a NaiveDateTime promoted with .and_utc(), so the UTC label is misleading — the inner value represents the player’s local time, not an absolute UTC instant. Use EventMetadata::local_timestamp() for the honest zone-less view, or EventMetadata::instant_utc() where the true UTC instant is available from an embedded event-payload field.

§Ambiguity

When day and month are both <= 12 and the separator is / (for example 02/05/2025 14:30:00), US format (M/d/yyyy) is tried before European (dd/MM/yyyy). The input above would therefore be interpreted as February 5, not May 2. There is no way to resolve this ambiguity without out-of-band locale information; consumers targeting European locales should be aware of this silent tie-break.

§Errors

Returns TimestampError::UnrecognizedFormat if no format matches, preserving the raw string for diagnostics.