formatting.rs |
Date and time formatting routines. |
39536 |
locales.rs |
|
2994 |
mod.rs |
Formatting (and parsing) utilities for date and time.
This module provides the common types and routines to implement,
for example, [`DateTime::format`](../struct.DateTime.html#method.format) or
[`DateTime::parse_from_str`](../struct.DateTime.html#method.parse_from_str) methods.
For most cases you should use these high-level interfaces.
Internally the formatting and parsing shares the same abstract **formatting items**,
which are just an [`Iterator`](https://doc.rust-lang.org/std/iter/trait.Iterator.html) of
the [`Item`](./enum.Item.html) type.
They are generated from more readable **format strings**;
currently Chrono supports a built-in syntax closely resembling
C's `strftime` format. The available options can be found [here](./strftime/index.html).
# Example
```
# #[cfg(feature = "alloc")] {
use chrono::{NaiveDateTime, TimeZone, Utc};
let date_time = Utc.with_ymd_and_hms(2020, 11, 10, 0, 1, 32).unwrap();
let formatted = format!("{}", date_time.format("%Y-%m-%d %H:%M:%S"));
assert_eq!(formatted, "2020-11-10 00:01:32");
let parsed = NaiveDateTime::parse_from_str(&formatted, "%Y-%m-%d %H:%M:%S")?.and_utc();
assert_eq!(parsed, date_time);
# }
# Ok::<(), chrono::ParseError>(())
``` |
20385 |
parse.rs |
Date and time parsing routines. |
95781 |
parsed.rs |
A collection of parsed date and time items.
They can be constructed incrementally while being checked for consistency. |
79388 |
scan.rs |
!
Various scanning routines for the parser.
|
14619 |
strftime.rs |
|
54670 |