Go to file
Kang Seonghoon d5f652e656 renamed `n<foo>s` to `num_<foo>s` and changed their semantics.
`Duration` now has a `to_tuple` method which corresponds to
the original `(dur.ndays(), dur.nseconds(), dur.nnanoseconds())`.
new `num_*s()` methods in `Duration` always return the integral
number of specified units in the duration.

cf. rust-lang/rust#15934
2014-07-25 21:00:32 +09:00
src renamed `n<foo>s` to `num_<foo>s` and changed their semantics. 2014-07-25 21:00:32 +09:00
.gitignore added Cargo support and updated .travis.yml; language changes: ToStr -> ToString. 2014-07-13 00:12:13 +09:00
.travis.yml updated .travis.yml to use install.sh for Cargo; src/chrono -> src. 2014-07-15 13:20:48 +09:00
Cargo.toml updated .travis.yml to use install.sh for Cargo; src/chrono -> src. 2014-07-15 13:20:48 +09:00
LICENSE.txt proper licensing, added README. 2014-04-02 02:14:57 +09:00
README.md renamed `chrono:📅:{MIN,MAX}` to `chrono:📅:{MINZ,MAXZ}`. 2014-07-25 19:24:32 +09:00

README.md

Rust-chrono

Rust-chrono on Travis CI

Date and time handling for Rust.

// find out if the doomsday rule is correct!
use chrono::{Weekday, DateZ, date};
use std::iter::range_inclusive;

for y in range_inclusive(date::MINZ.year(), date::MAXZ.year()) {
    // even months
    let d4   = DateZ::from_ymd(y,  4,  4);
    let d6   = DateZ::from_ymd(y,  6,  6);
    let d8   = DateZ::from_ymd(y,  8,  8);
    let d10  = DateZ::from_ymd(y, 10, 10);
    let d12  = DateZ::from_ymd(y, 12, 12);

    // nine to five, seven-eleven
    let d59  = DateZ::from_ymd(y,  5,  9);
    let d95  = DateZ::from_ymd(y,  9,  5);
    let d711 = DateZ::from_ymd(y,  7, 11);
    let d117 = DateZ::from_ymd(y, 11,  7);

    // "March 0"
    let d30  = DateZ::from_ymd(y,  3,  1).pred();

    let weekday = d30.weekday();
    let other_dates = [d4, d6, d8, d10, d12, d59, d95, d711, d117];
    assert!(other_dates.iter().all(|d| d.weekday() == weekday));
}

Design Goals

  • 1-to-1 correspondence with ISO 8601.
  • Timezone-aware by default.
  • Space efficient.
  • Moderate lookup table size, should not exceed a few KBs.
  • Avoid divisions as much as possible.

References