MoosicBox Date Utilities
Date and time parsing utilities with flexible format support.
Overview
The MoosicBox Date Utilities package provides:
- Flexible Date Parsing: Parse various date and time formats
- Chrono Integration: Built on the Chrono date/time library
- Format Detection: Automatic format detection and parsing
- Error Handling: Comprehensive parsing error management
Features
Date Format Support
- Year Only: "2023" → NaiveDateTime
- Date Only: "2023-12-25" → NaiveDateTime
- ISO 8601: "2023-12-25T15:30:45Z" → NaiveDateTime
- With UTC Offset (+00:00 only): "2023-12-25T15:30:45+00:00" → NaiveDateTime
- With Microseconds: "2023-12-25T15:30:45.123456" → NaiveDateTime
Installation
Add this to your Cargo.toml:
[]
= { = "../date_utils" }
The chrono feature is enabled by default. To use without chrono:
[]
= { = "../date_utils", = false }
Usage
Basic Date Parsing
use parse_date_time;
// Parse various formats
let year_only = parse_date_time?;
let date_only = parse_date_time?;
let iso_format = parse_date_time?;
let with_tz = parse_date_time?;
let with_micros = parse_date_time?;
parse_date_time supports UTC datetime strings with Z or +00:00 offsets.
Dependencies
- Chrono: Date and time library
- Log: Error logging