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.
-
macrosEnables macros that provide compile-time verification of values and intuitive syntax.
-
formatting(implicitly enablesstd)Enables formatting of most structs.
-
parsingEnables parsing of most structs.
-
local-offset(implicitly enablesstd)This feature enables a number of methods that allow obtaining the system’s UTC offset.
-
large-datesBy 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.
-
serdeEnables
serdesupport for all types. -
serde-human-readable(implicitly enablesserde,formatting, andparsing)Allows
serderepresentations 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(implicitly enablesrand08andrand09)Previously, this would enable support for
rand0.8. Since the release ofrand0.9, the feature has been split intorand08andrand09to allow support for both versions. For backwards compatibility and simplicity, this feature enables support for both series.It is strongly recommended to enable
rand08orrand09directly, as enablingrandwill needlessly pull in both versions. -
rand08Enables
rand0.8 support for all types. -
rand09Enables
rand0.9 support for all types. -
quickcheck(implicitly enablesalloc)Enables quickcheck support for all types.
-
wasm-bindgenEnables
wasm-bindgensupport for converting JavaScript dates, as well as obtaining the UTC offset from JavaScript.
Re-exports§
pub use crate::date::Date;pub use crate::duration::Duration;pub use crate::error::Error;#[doc(hidden)] pub use crate::instant::Instant;Deprecated stdpub use crate::month::Month;pub use crate::offset_date_time::OffsetDateTime;pub use crate::primitive_date_time::PrimitiveDateTime;pub use crate::time::Time;pub use crate::utc_date_time::UtcDateTime;pub use crate::utc_offset::UtcOffset;pub use crate::weekday::Weekday;
Modules§
- convert
- Conversion between units of time.
- date 🔒
- The
Datestruct and its associatedimpls. - duration 🔒
- The
Durationstruct and its associatedimpls. - error
- Various error types returned by methods in the time crate.
- ext
- Extension traits.
- format_
description formattingorparsing - Description of how types should be formatted and parsed.
- formatting
formatting - Formatting for various types.
- hint 🔒
- Hints to the compiler that affects how code should be emitted or optimized.
- instant 🔒
std - The
Instantstruct and its associatedimpls. - internal_
macros 🔒 - Macros for use within the library. They are not publicly available.
- interop 🔒
- Comparison, arithmetic, and conversion between various types in
timeand the standard library. - macros
macros - Macros to construct statically known values.
- month 🔒
- The
Monthenum and its associatedimpls. - offset_
date_ 🔒time - The
OffsetDateTimestruct and its associatedimpls. - parsing
parsing - Parsing for various types.
- primitive_
date_ 🔒time - The
PrimitiveDateTimestruct and its associatedimpls. - quickcheck 🔒
quickcheck - Implementations of the
quickcheck::Arbitrarytrait. - rand08 🔒
rand08 - Implementation of
Distributionfor various structs. - rand09 🔒
rand09 - Implementation of
Distributionfor various structs. - serde
serde - Differential formats for serde.
- sys 🔒
- Functions with a common interface that rely on system calls.
- time 🔒
- The
Timestruct and its associatedimpls. - utc_
date_ 🔒time - The
UtcDateTimestruct and associatedimpls. - utc_
offset 🔒 - The
UtcOffsetstruct and its associatedimpls. - util
- Utility functions, including updating time zone information.
- weekday 🔒
- Days of the week.
Functions§
- expect_
failed 🔒 - This is a separate function to reduce the code size of
expect_opt!. - size_
of_ 🔒val - Returns the size of the pointed-to value in bytes.
Type Aliases§
- Result
- An alias for
std::result::Resultwith a generic error from the time crate.