pub fn utcize<S>(
s: &str,
fallback_tz: &str,
prefer_eu: bool,
usr_custom_formats: Option<&[S]>,
) -> Result<DateTime<Utc>, TimeParseError>Expand description
Parses a datetime string into a DateTime<Utc>, accepting a wide variety of formats.
This function supports:
- Unix epoch (seconds, milliseconds, microseconds, nanoseconds)
- ISO 8601, RFC 3339, RFC 2822
- Flexible date/time formats (with optional European preference)
- Fallback timezone if input has no timezone
§Arguments
s- The input datetime string.fallback_tz- Timezone used if input is naive (e.g.,Asia/Jakarta,+07:00,UTC).prefer_eu- If true, will try European formats first (e.g., DD-MM-YYYY).usr_custom_formats- Optional list of custom formats to try before defaults.
§Returns
Ok(DateTime<Utc>)- Normalized UTC datetime.Err(TimeParseError)- If parsing fails or time is ambiguous.