Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Date and time library for Rust

License

NotificationsYou must be signed in to change notification settings

chronotope/chrono

Repository files navigation

Chrono: Timezone-aware date and time handling

Chrono GitHub ActionsChrono on crates.ioChrono on docs.rsChatcodecov.io

Chrono aims to provide all functionality needed to do correct operations on dates and times in theproleptic Gregorian calendar:

  • TheDateTime type is timezone-awareby default, with separate timezone-naive types.
  • Operations that may produce an invalid or ambiguous date and time returnOption orMappedLocalTime.
  • Configurable parsing and formatting with anstrftime inspired date and time formatting syntax.
  • TheLocal timezone works withthe current timezone of the OS.
  • Types and operations are implemented to be reasonably efficient.

Timezone data is not shipped with chrono by default to limit binary sizes. Use the companion crateChrono-TZ ortzfile forfull timezone support.

Documentation

Seedocs.rs for the API reference.

Limitations

  • Only the proleptic Gregorian calendar (i.e. extended to support older dates) is supported.
  • Date types are limited to about +/- 262,000 years from the common epoch.
  • Time types are limited to nanosecond accuracy.
  • Leap seconds can be represented, but Chrono does not fully support them.SeeLeap Second Handling.

Crate features

Default features:

  • alloc: Enable features that depend on allocation (primarily string formatting).
  • std: Enables functionality that depends on the standard library. This is a superset ofallocand adds interoperation with standard library types and traits.
  • clock: Enables reading the local timezone (Local). This is a superset ofnow.
  • now: Enables reading the system time (now).
  • wasmbind: Interface with the JS Date API for thewasm32 target.

Optional features:

  • serde: Enable serialization/deserialization viaserde.
  • rkyv: Deprecated, use therkyv-* features.
  • rkyv-16: Enable serialization/deserialization viarkyv, using 16-bit integers for integral*size types.
  • rkyv-32: Enable serialization/deserialization viarkyv, using 32-bit integers for integral*size types.
  • rkyv-64: Enable serialization/deserialization viarkyv, using 64-bit integers for integral*size types.
  • rkyv-validation: Enable rkyv validation support usingbytecheck.
  • arbitrary: Construct arbitrary instances of a type with the Arbitrary crate.
  • unstable-locales: Enable localization. This adds various methods with a_localized suffix.The implementation and API may change or even be removed in a patch release. Feedback welcome.
  • oldtime: This feature no longer has any effect; it used to offer compatibility with thetime 0.1 crate.

Note: Therkyv{,-16,-32,-64} features are mutually exclusive.

Rust version requirements

The Minimum Supported Rust Version (MSRV) is currentlyRust 1.61.0.

The MSRV is explicitly tested in CI. It may be bumped in minor releases, but this is not donelightly.

License

This project is licensed under either of

at your option.


[8]ページ先頭

©2009-2025 Movatter.jp