Expand description
Formatting (and parsing) utilities for date and time.
This module provides the common types and routines to implement,
for example, DateTime::format
or
DateTime::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
of
the Item
type.
They are generated from more readable format strings;
currently Chrono supports one built-in syntax closely resembling
C’s strftime
format.
Modules§
- strftime
strftime
/strptime
-inspired date and time formatting syntax.
Structs§
- Delayed
Format - A temporary object which can be used as an argument to
format!
or others. This is normally constructed viaformat
methods of each date and time type. - Internal
Fixed - An opaque type representing fixed-format item types for internal uses only.
- Internal
Numeric - An opaque type representing numeric item types for internal uses only.
- Parse
Error - An error from the
parse
function. - Parsed
- Parsed parts of date and time. There are two classes of methods:
- Strftime
Items - Parsing iterator for
strftime
-like format strings.
Enums§
- Fixed
- Fixed-format item types.
- Item
- A single formatting item. This is used for both formatting and parsing.
- Numeric
- Numeric item types. They have associated formatting width (FW) and parsing width (PW).
- Pad
- Padding characters for numeric items.
Functions§
- format
- Tries to format given arguments with given formatting items.
Internally used by
DelayedFormat
. - parse
- Tries to parse given string into
parsed
with given formatting items. ReturnsOk
when the entire string has been parsed (otherwiseparsed
should not be used). There should be no trailing string after parsing; use a strayItem::Space
to trim whitespaces.
Type Aliases§
- Parse
Result - Same as
Result<T, ParseError>
.