All Projects → Rapptz → eos

Rapptz / eos

Licence: Apache-2.0 license
A simple and easy to use datetime library for Rust

Programming Languages

rust
11053 projects
python
139335 projects - #7 most used programming language

eos

eos is a datetime library for Rust, aimed at being robust, simple, and easy to use. eos is made with the assumption of operating under a proleptic Gregorian calendar. If you're looking for different calendar systems, similar to those in JavaScript's Temporal library, then this library is not for you. However, I am open to the idea of having calendar systems in the future.

Right now, this library is in its development phase.

Why?

There already exist well established libraries in the ecosystem to deal with both dates and times so it's fair to be skeptical of any new library in this space. However, this library was created due to inadequacies in current offerings when it came to more complicated use cases (such as timezones). I had wanted to create a library that was both simpler, more robust, and correct when it came to the complexities of dealing with time.

Special care has been taken to ensure timezones are implemented properly. To that end, there is no concept of a naive date time. The default timezone of a DateTime type is UTC. All operations done on a DateTime are timezone aware. For example, comparisons are done by comparing the same instant of time in UTC or within the same timezone. Despite having timezone support, the chrono crate does not do this. Which can lead to surprising behaviour.

Since timezone information can be a bit heavy on resources and not something every applicationw ants to concern itself with, the IANA database backed TimeZone implementation is in another crate, eos-tz. The base library only has Utc, UtcOffset, and System for their concrete timezone implementations.

Features

eos supports no_std targets and some optional features.

Default features:

  • alloc: Enable features that require allocation.
  • macros: Enables the compile-time construction macros. Most of these use macro_rules! rather than the proc-macro machinery to keep compile times sane. Unfortunately, due to limitations in const fn, the format_spec! macro uses proc-macro machinery. To keep compile-times sane for this macro, syn and quote are not used.
  • std: Enable features that require the standard library. Implies alloc.
  • system: Enable features that allow retrieving system time information. Requires libc on POSIX.
  • formatting: Enable features relating to formatting various types. Implies alloc.
  • parsing: Enable features relating to parsing strings to various types. Implies alloc.

Optional features:

  • serde: Enable custom Serialize/Deserialize implementations. Requires parsing as well.

Acknowledgements

The design of this library was inspired by the following:

Certain algorithms come from one of these libraries above. Likewise, due to the difficult nature of testing datetimes, certain tests were adapted from one of these libraries as well to have better test coverage.

Without these libraries, this one would not be possible. eos stands on the shoulder of giants.

License

This project is licensed under the Apache-2 license.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in eos by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].