0.1.11: language changes.
- Boxed closures are gone; some unboxed closures require an explicit annotation for kinds (`&:` in most cases).
This commit is contained in:
parent
883b656d49
commit
e97993d76a
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.1.10"
|
version = "0.1.11"
|
||||||
authors = ["Kang Seonghoon <public+rust@mearie.org>"]
|
authors = ["Kang Seonghoon <public+rust@mearie.org>"]
|
||||||
|
|
||||||
description = "Date and time library for Rust"
|
description = "Date and time library for Rust"
|
||||||
|
@ -15,5 +15,5 @@ license = "MIT/Apache-2.0"
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
time = "0.1.9"
|
time = "0.1.10"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[Chrono][doc] 0.1.10
|
[Chrono][doc] 0.1.11
|
||||||
====================
|
====================
|
||||||
|
|
||||||
[![Chrono on Travis CI][travis-image]][travis]
|
[![Chrono on Travis CI][travis-image]][travis]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
# Chrono 0.1.10
|
# Chrono 0.1.11
|
||||||
|
|
||||||
Date and time handling for Rust. (also known as `rust-chrono`)
|
Date and time handling for Rust. (also known as `rust-chrono`)
|
||||||
It aims to be a feature-complete superset of the [time](https://github.com/rust-lang/time) library.
|
It aims to be a feature-complete superset of the [time](https://github.com/rust-lang/time) library.
|
||||||
|
|
|
@ -449,7 +449,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date_from_ymd() {
|
fn test_date_from_ymd() {
|
||||||
let ymd_opt = |y,m,d| NaiveDate::from_ymd_opt(y, m, d);
|
let ymd_opt = |&: y,m,d| NaiveDate::from_ymd_opt(y, m, d);
|
||||||
|
|
||||||
assert!(ymd_opt(2012, 0, 1).is_none());
|
assert!(ymd_opt(2012, 0, 1).is_none());
|
||||||
assert!(ymd_opt(2012, 1, 1).is_some());
|
assert!(ymd_opt(2012, 1, 1).is_some());
|
||||||
|
@ -465,8 +465,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date_from_yo() {
|
fn test_date_from_yo() {
|
||||||
let yo_opt = |y,o| NaiveDate::from_yo_opt(y, o);
|
let yo_opt = |&: y,o| NaiveDate::from_yo_opt(y, o);
|
||||||
let ymd = |y,m,d| NaiveDate::from_ymd(y, m, d);
|
let ymd = |&: y,m,d| NaiveDate::from_ymd(y, m, d);
|
||||||
|
|
||||||
assert_eq!(yo_opt(2012, 0), None);
|
assert_eq!(yo_opt(2012, 0), None);
|
||||||
assert_eq!(yo_opt(2012, 1), Some(ymd(2012, 1, 1)));
|
assert_eq!(yo_opt(2012, 1), Some(ymd(2012, 1, 1)));
|
||||||
|
@ -495,8 +495,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date_from_isoywd() {
|
fn test_date_from_isoywd() {
|
||||||
let isoywd_opt = |y,w,d| NaiveDate::from_isoywd_opt(y, w, d);
|
let isoywd_opt = |&: y,w,d| NaiveDate::from_isoywd_opt(y, w, d);
|
||||||
let ymd = |y,m,d| NaiveDate::from_ymd(y, m, d);
|
let ymd = |&: y,m,d| NaiveDate::from_ymd(y, m, d);
|
||||||
|
|
||||||
assert_eq!(isoywd_opt(2004, 0, Weekday::Sun), None);
|
assert_eq!(isoywd_opt(2004, 0, Weekday::Sun), None);
|
||||||
assert_eq!(isoywd_opt(2004, 1, Weekday::Mon), Some(ymd(2003, 12, 29)));
|
assert_eq!(isoywd_opt(2004, 1, Weekday::Mon), Some(ymd(2003, 12, 29)));
|
||||||
|
@ -558,7 +558,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date_from_num_days_from_ce() {
|
fn test_date_from_num_days_from_ce() {
|
||||||
let from_ndays_from_ce = |days| NaiveDate::from_num_days_from_ce_opt(days);
|
let from_ndays_from_ce = |&: days| NaiveDate::from_num_days_from_ce_opt(days);
|
||||||
assert_eq!(from_ndays_from_ce(1), Some(NaiveDate::from_ymd(1, 1, 1)));
|
assert_eq!(from_ndays_from_ce(1), Some(NaiveDate::from_ymd(1, 1, 1)));
|
||||||
assert_eq!(from_ndays_from_ce(2), Some(NaiveDate::from_ymd(1, 1, 2)));
|
assert_eq!(from_ndays_from_ce(2), Some(NaiveDate::from_ymd(1, 1, 2)));
|
||||||
assert_eq!(from_ndays_from_ce(31), Some(NaiveDate::from_ymd(1, 1, 31)));
|
assert_eq!(from_ndays_from_ce(31), Some(NaiveDate::from_ymd(1, 1, 31)));
|
||||||
|
@ -685,7 +685,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date_succ() {
|
fn test_date_succ() {
|
||||||
let ymd = |y,m,d| NaiveDate::from_ymd(y, m, d);
|
let ymd = |&: y,m,d| NaiveDate::from_ymd(y, m, d);
|
||||||
assert_eq!(ymd(2014, 5, 6).succ_opt(), Some(ymd(2014, 5, 7)));
|
assert_eq!(ymd(2014, 5, 6).succ_opt(), Some(ymd(2014, 5, 7)));
|
||||||
assert_eq!(ymd(2014, 5, 31).succ_opt(), Some(ymd(2014, 6, 1)));
|
assert_eq!(ymd(2014, 5, 31).succ_opt(), Some(ymd(2014, 6, 1)));
|
||||||
assert_eq!(ymd(2014, 12, 31).succ_opt(), Some(ymd(2015, 1, 1)));
|
assert_eq!(ymd(2014, 12, 31).succ_opt(), Some(ymd(2015, 1, 1)));
|
||||||
|
@ -695,7 +695,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_date_pred() {
|
fn test_date_pred() {
|
||||||
let ymd = |y,m,d| NaiveDate::from_ymd(y, m, d);
|
let ymd = |&: y,m,d| NaiveDate::from_ymd(y, m, d);
|
||||||
assert_eq!(ymd(2016, 3, 1).pred_opt(), Some(ymd(2016, 2, 29)));
|
assert_eq!(ymd(2016, 3, 1).pred_opt(), Some(ymd(2016, 2, 29)));
|
||||||
assert_eq!(ymd(2015, 1, 1).pred_opt(), Some(ymd(2014, 12, 31)));
|
assert_eq!(ymd(2015, 1, 1).pred_opt(), Some(ymd(2014, 12, 31)));
|
||||||
assert_eq!(ymd(2014, 6, 1).pred_opt(), Some(ymd(2014, 5, 31)));
|
assert_eq!(ymd(2014, 6, 1).pred_opt(), Some(ymd(2014, 5, 31)));
|
||||||
|
|
|
@ -223,8 +223,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_datetime_from_num_seconds_from_unix_epoch() {
|
fn test_datetime_from_num_seconds_from_unix_epoch() {
|
||||||
let from_timestamp = |secs| NaiveDateTime::from_num_seconds_from_unix_epoch_opt(secs, 0);
|
let from_timestamp = |&: secs| NaiveDateTime::from_num_seconds_from_unix_epoch_opt(secs, 0);
|
||||||
let ymdhms = |y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s);
|
let ymdhms = |&: y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s);
|
||||||
assert_eq!(from_timestamp(-1), Some(ymdhms(1969, 12, 31, 23, 59, 59)));
|
assert_eq!(from_timestamp(-1), Some(ymdhms(1969, 12, 31, 23, 59, 59)));
|
||||||
assert_eq!(from_timestamp(0), Some(ymdhms(1970, 1, 1, 0, 0, 0)));
|
assert_eq!(from_timestamp(0), Some(ymdhms(1970, 1, 1, 0, 0, 0)));
|
||||||
assert_eq!(from_timestamp(1), Some(ymdhms(1970, 1, 1, 0, 0, 1)));
|
assert_eq!(from_timestamp(1), Some(ymdhms(1970, 1, 1, 0, 0, 1)));
|
||||||
|
@ -236,7 +236,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_datetime_add() {
|
fn test_datetime_add() {
|
||||||
let ymdhms = |y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s);
|
let ymdhms = |&: y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s);
|
||||||
assert_eq!(ymdhms(2014, 5, 6, 7, 8, 9) + Duration::seconds(3600 + 60 + 1),
|
assert_eq!(ymdhms(2014, 5, 6, 7, 8, 9) + Duration::seconds(3600 + 60 + 1),
|
||||||
ymdhms(2014, 5, 6, 8, 9, 10));
|
ymdhms(2014, 5, 6, 8, 9, 10));
|
||||||
assert_eq!(ymdhms(2014, 5, 6, 7, 8, 9) + Duration::seconds(-(3600 + 60 + 1)),
|
assert_eq!(ymdhms(2014, 5, 6, 7, 8, 9) + Duration::seconds(-(3600 + 60 + 1)),
|
||||||
|
@ -251,7 +251,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_datetime_sub() {
|
fn test_datetime_sub() {
|
||||||
let ymdhms = |y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s);
|
let ymdhms = |&: y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s);
|
||||||
assert_eq!(ymdhms(2014, 5, 6, 7, 8, 9) - ymdhms(2014, 5, 6, 7, 8, 9), Duration::zero());
|
assert_eq!(ymdhms(2014, 5, 6, 7, 8, 9) - ymdhms(2014, 5, 6, 7, 8, 9), Duration::zero());
|
||||||
assert_eq!(ymdhms(2014, 5, 6, 7, 8, 10) - ymdhms(2014, 5, 6, 7, 8, 9),
|
assert_eq!(ymdhms(2014, 5, 6, 7, 8, 10) - ymdhms(2014, 5, 6, 7, 8, 9),
|
||||||
Duration::seconds(1));
|
Duration::seconds(1));
|
||||||
|
@ -265,8 +265,8 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_datetime_num_seconds_from_unix_epoch() {
|
fn test_datetime_num_seconds_from_unix_epoch() {
|
||||||
let to_timestamp =
|
let to_timestamp = |&: y,m,d,h,n,s|
|
||||||
|y,m,d,h,n,s| NaiveDate::from_ymd(y,m,d).and_hms(h,n,s).num_seconds_from_unix_epoch();
|
NaiveDate::from_ymd(y,m,d).and_hms(h,n,s).num_seconds_from_unix_epoch();
|
||||||
assert_eq!(to_timestamp(1969, 12, 31, 23, 59, 59), -1);
|
assert_eq!(to_timestamp(1969, 12, 31, 23, 59, 59), -1);
|
||||||
assert_eq!(to_timestamp(1970, 1, 1, 0, 0, 0), 0);
|
assert_eq!(to_timestamp(1970, 1, 1, 0, 0, 0), 0);
|
||||||
assert_eq!(to_timestamp(1970, 1, 1, 0, 0, 1), 1);
|
assert_eq!(to_timestamp(1970, 1, 1, 0, 0, 1), 1);
|
||||||
|
|
|
@ -317,7 +317,7 @@ mod tests {
|
||||||
assert_eq!(rhs + lhs, sum);
|
assert_eq!(rhs + lhs, sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hmsm = |h,m,s,mi| NaiveTime::from_hms_milli(h, m, s, mi);
|
let hmsm = |&: h,m,s,mi| NaiveTime::from_hms_milli(h, m, s, mi);
|
||||||
|
|
||||||
check(hmsm(3, 5, 7, 900), Duration::zero(), hmsm(3, 5, 7, 900));
|
check(hmsm(3, 5, 7, 900), Duration::zero(), hmsm(3, 5, 7, 900));
|
||||||
check(hmsm(3, 5, 7, 900), Duration::milliseconds(100), hmsm(3, 5, 8, 0));
|
check(hmsm(3, 5, 7, 900), Duration::milliseconds(100), hmsm(3, 5, 8, 0));
|
||||||
|
@ -335,7 +335,7 @@ mod tests {
|
||||||
assert_eq!(rhs - lhs, -diff);
|
assert_eq!(rhs - lhs, -diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
let hmsm = |h,m,s,mi| NaiveTime::from_hms_milli(h, m, s, mi);
|
let hmsm = |&: h,m,s,mi| NaiveTime::from_hms_milli(h, m, s, mi);
|
||||||
|
|
||||||
check(hmsm(3, 5, 7, 900), hmsm(3, 5, 7, 900), Duration::zero());
|
check(hmsm(3, 5, 7, 900), hmsm(3, 5, 7, 900), Duration::zero());
|
||||||
check(hmsm(3, 5, 7, 900), hmsm(3, 5, 7, 600), Duration::milliseconds(300));
|
check(hmsm(3, 5, 7, 900), hmsm(3, 5, 7, 600), Duration::milliseconds(300));
|
||||||
|
|
Loading…
Reference in New Issue