2014-04-01 17:14:57 +00:00
|
|
|
// This is a part of rust-chrono.
|
|
|
|
// Copyright (c) 2014, Kang Seonghoon.
|
|
|
|
// See README.md and LICENSE.txt for details.
|
|
|
|
|
2014-07-25 09:12:51 +00:00
|
|
|
/*!
|
|
|
|
Experimental date and time handling for Rust.
|
|
|
|
*/
|
|
|
|
|
2014-04-01 17:14:57 +00:00
|
|
|
#![comment = "Date and time library for Rust"]
|
|
|
|
#![license = "MIT"]
|
2014-03-28 11:38:11 +00:00
|
|
|
|
2014-07-15 03:53:40 +00:00
|
|
|
#![feature(macro_rules)]
|
2014-07-25 09:12:51 +00:00
|
|
|
#![deny(missing_doc)]
|
2014-03-31 05:33:47 +00:00
|
|
|
|
|
|
|
extern crate num;
|
2014-03-28 11:38:11 +00:00
|
|
|
|
2014-07-25 08:05:26 +00:00
|
|
|
pub use duration::Duration;
|
|
|
|
pub use date::{Weekday, Mon, Tue, Wed, Thu, Fri, Sat, Sun};
|
2014-07-29 06:55:40 +00:00
|
|
|
pub use date::{Datelike, NaiveDate};
|
|
|
|
pub use time::{Timelike, NaiveTime};
|
|
|
|
pub use datetime::NaiveDateTime;
|
2014-07-19 17:51:57 +00:00
|
|
|
|
2014-03-29 08:20:39 +00:00
|
|
|
pub mod duration;
|
2014-07-29 06:41:07 +00:00
|
|
|
pub mod offset;
|
2014-03-28 11:38:11 +00:00
|
|
|
pub mod date;
|
|
|
|
pub mod time;
|
|
|
|
pub mod datetime;
|
|
|
|
|
2014-07-19 17:51:57 +00:00
|
|
|
#[test]
|
|
|
|
fn test_readme_doomsday() {
|
|
|
|
use std::iter::range_inclusive;
|
|
|
|
|
2014-07-29 06:55:40 +00:00
|
|
|
for y in range_inclusive(date::MIN_NAIVE.year(), date::MAX_NAIVE.year()) {
|
2014-07-19 17:51:57 +00:00
|
|
|
// even months
|
2014-07-29 06:55:40 +00:00
|
|
|
let d4 = NaiveDate::from_ymd(y, 4, 4);
|
|
|
|
let d6 = NaiveDate::from_ymd(y, 6, 6);
|
|
|
|
let d8 = NaiveDate::from_ymd(y, 8, 8);
|
|
|
|
let d10 = NaiveDate::from_ymd(y, 10, 10);
|
|
|
|
let d12 = NaiveDate::from_ymd(y, 12, 12);
|
2014-07-19 17:51:57 +00:00
|
|
|
|
|
|
|
// nine to five, seven-eleven
|
2014-07-29 06:55:40 +00:00
|
|
|
let d59 = NaiveDate::from_ymd(y, 5, 9);
|
|
|
|
let d95 = NaiveDate::from_ymd(y, 9, 5);
|
|
|
|
let d711 = NaiveDate::from_ymd(y, 7, 11);
|
|
|
|
let d117 = NaiveDate::from_ymd(y, 11, 7);
|
2014-07-19 17:51:57 +00:00
|
|
|
|
|
|
|
// "March 0"
|
2014-07-29 06:55:40 +00:00
|
|
|
let d30 = NaiveDate::from_ymd(y, 3, 1).pred();
|
2014-07-19 17:51:57 +00:00
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|