Crate time[][src]

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 enables alloc)

    This enables a number of features that depend on the standard library. Instant is the primary item that requires this feature, though some others methods may rely on Instant internally.

  • alloc (enabled by default via std)

    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 enables std)

    Enables formatting of most structs.

  • parsing

    Enables parsing of most structs.

  • local-offset (implicitly enables std)

    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.

    If you are using this feature, please leave a comment on this discussion with your use case. If there is not sufficient demand for this feature, it will be dropped in a future release.

  • serde

    Enables serde support for all types.

  • serde-human-readable (implicitly enables serde, formatting, and parsing)

    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.

  • rand

    Enables rand support for all types.

  • quickcheck (implicitly enables alloc)

    Enables quickcheck support for all types except Instant.

One pseudo-feature flag that is only available to end users is the unsound_local_offset cfg. As the name indicates, using the feature is unsound, and may cause unexpected segmentation faults. Unlike other flags, this is deliberately only available to end users; this is to ensure that a user doesn’t have unsound behavior without knowing it. To enable this behavior, you must use RUSTFLAGS="--cfg unsound_local_offset" cargo build or similar. Note: This flag is not tested anywhere, including in the regular test of the powerset of all feature flags. Use at your own risk.

Re-exports

pub use crate::error::Error;

Modules

The Date struct and its associated impls.

The Duration struct and its associated impls.

Various error types returned by methods in the time crate.

Extension traits.

formatting or parsing

Description of how types should be formatted and parsed.

formatting

Formatting for various types.

std

The Instant struct and its associated impls.

macros

Macros to construct statically known values.

The Month enum and its associated impls.

The OffsetDateTime struct and its associated impls.

parsing

Parsing for various types.

The PrimitiveDateTime struct and its associated impls.

quickcheck

Implementations of the quickcheck::Arbitrary trait.

rand

Implementation of Distribution for various structs.

serde

Differential formats for serde.

The Time struct and its associated impls.

The UtcOffset struct and its associated impls.

Utility functions.

Days of the week.

Structs

Date in the proleptic Gregorian calendar.

A span of time with nanosecond precision.

std

A measurement of a monotonically non-decreasing clock. Opaque and useful only with Duration.

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.

Type Definitions

An alias for std::result::Result with a generic error from the time crate.