| Crates.io | datetime_literal |
| lib.rs | datetime_literal |
| version | 0.1.3 |
| created_at | 2025-01-09 22:08:21.385467+00 |
| updated_at | 2025-01-21 21:08:02.037559+00 |
| description | A macro for creating chrono::DateTime instances. |
| homepage | |
| repository | https://github.com/avl/datetime_literal |
| max_upload_size | |
| id | 1510624 |
| size | 5,215 |
This is an extremely simple crate that provides a macro for easily creating instances of chrono's DateTime:
Examples:
assert_eq!(
datetime!(2024-01-02 13:14:15),
"2024-01-02T13:14:15".parse().unwrap()
);
assert_eq!(
datetime!(2024-01-02 13:14:15 Z),
"2024-01-02T13:14:15Z".parse::<chrono::DateTime<chrono::Utc>>().unwrap()
);
assert_eq!(
datetime!(2024-01-02 T 13:14:15),
"2024-01-02T13:14:15".parse().unwrap()
);
assert_eq!(
datetime!(2024-01-02 T 13:14:15 Z),
"2024-01-02T13:14:15Z".parse::<chrono::DateTime<chrono::Utc>>().unwrap()
);
assert_eq!(
datetime!(2024-01-02),
"2024-01-02T00:00:00".parse().unwrap()
);
assert_eq!(
datetime!(2024-01-02 Z),
"2024-01-02T00:00:00Z".parse::<chrono::DateTime<chrono::Utc>>().unwrap()
);
Note! Because of how rust macros work, you must leave space before/after 'T', and before 'Z'.