Overview
Astrolabe is a date and time library for Rust which aims to be feature rich, lightweight (zero dependencies) and easy-to-use. It is build around DateTime, a wrapper around std::time::SystemTime which implements formatting and manipulation functions.
Features
- Formatting
- RFC3339 timestamp
- Formatting with format strings based on Unicode Date Field Symbols. (Which allows formatting
SystemTimeinto basically any string format)
- Manipulation
- Manipulation functions like
DateTime::addorDateTime::subto create a new, modifiedDateTimeinstance
- Manipulation functions like
- Timezone
- Specify a timezone offset which will be applied in any format function
- Zero dependencies
Example
A basic example which demonstrates creating, formatting and manipulating a DateTime instance.
use ;
// Create a DateTime instance from year, month, and days (day of month)
let date_time = from_ymd.unwrap;
// Use the format function to freely format your DateTime instance
assert_eq!;
// Create a new instance with a modified DateTime
// The previous instance is not modified and is still in scope
let modified_dt = date_time.add.add;
assert_eq!;
assert_eq!;
To see all implementations for the DateTime struct, check out it's documentation.
MSRV
This crate uses the Rust 2021 Edition and requires at least version 1.56.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.