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.

All timestamps are treated as UTC (MTGA does not include timezone information in log entry headers).

§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.