Expand description
§Feature flags
This crate exposes a number of features. These can be enabled or disabled as shown in Cargo’s documentation. Features are disabled by default unless otherwise noted.
Reliance on a given feature is always indicated alongside the item definition.
-
std
(enabled by default, implicitly enablesalloc
)This enables a number of features that depend on the standard library.
-
alloc
(enabled by default viastd
)Enables a number of features that require the ability to dynamically allocate memory.
-
macros
Enables macros that provide compile-time verification of values and intuitive syntax.
-
formatting
(implicitly enablesstd
)Enables formatting of most structs.
-
parsing
Enables parsing of most structs.
-
local-offset
(implicitly enablesstd
)This feature enables a number of methods that allow obtaining the system’s UTC offset.
-
large-dates
By default, only years within the ±9999 range (inclusive) are supported. If you need support for years outside this range, consider enabling this feature; the supported range will be increased to ±999,999.
Note that enabling this feature has some costs, as it means forgoing some optimizations. Ambiguities may be introduced when parsing that would not otherwise exist.
-
serde
-
serde-human-readable
(implicitly enablesserde
,formatting
, andparsing
)Allows serde representations to use a human-readable format. This is determined by the serializer, not the user. If this feature is not enabled or if the serializer requests a non-human-readable format, a format optimized for binary representation will be used.
Libraries should never enable this feature, as the decision of what format to use should be up to the user.
-
rand
Enables rand support for all types.
-
quickcheck
(implicitly enablesalloc
)Enables quickcheck support for all types except
Instant
. -
wasm-bindgen
Enables wasm-bindgen support for converting JavaScript dates, as well as obtaining the UTC offset from JavaScript.
Re-exports§
pub use crate::error::Error;
Modules§
- Conversion between units of time.
- date 🔒The
Date
struct and its associatedimpl
s. - duration 🔒The
Duration
struct and its associatedimpl
s. - Various error types returned by methods in the time crate.
- Extension traits.
- Description of how types should be formatted and parsed.
- Formatting for various types.
- instant 🔒The
Instant
struct and its associatedimpl
s. - Macros for use within the library. They are not publicly available.
- Macros to construct statically known values.
- month 🔒The
Month
enum and its associatedimpl
s. - The
OffsetDateTime
struct and its associatedimpl
s. - Parsing for various types.
- The
PrimitiveDateTime
struct and its associatedimpl
s. - Differential formats for serde.
- sys 🔒Functions with a common interface that rely on system calls.
- time 🔒The
Time
struct and its associatedimpl
s. - The
UtcOffset
struct and its associatedimpl
s. - Utility functions.
- weekday 🔒Days of the week.
Structs§
- Date in the proleptic Gregorian calendar.
- A span of time with nanosecond precision.
- InstantDeprecatedA measurement of a monotonically non-decreasing clock. Opaque and useful only with
Duration
. - A
PrimitiveDateTime
with aUtcOffset
. - Combined date and time.
- The clock time within a given date. Nanosecond precision.
- An offset from UTC.
Enums§
- Months of the year.
- Days of the week.
Functions§
- This is a separate function to reduce the code size of
expect_opt!
.
Type Aliases§
- An alias for
std::result::Result
with a generic error from the time crate.