diff --git a/Cargo.toml b/Cargo.toml index ca7635a..a764b39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chrono" -version = "0.1.13" +version = "0.1.14" authors = ["Kang Seonghoon "] description = "Date and time library for Rust" diff --git a/src/datetime.rs b/src/datetime.rs index b2341f2..9b40883 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -221,8 +221,9 @@ impl fmt::String for DateTime { #[cfg(test)] mod tests { + use {Datelike}; use duration::Duration; - use offset::{Offset, UTC, FixedOffset}; + use offset::{Offset, UTC, Local, FixedOffset}; #[test] #[allow(non_snake_case)] @@ -249,5 +250,12 @@ mod tests { assert_eq!(*EDT.ymd(2014, 5, 6).and_hms(7, 8, 9).offset(), EDT); assert!(*EDT.ymd(2014, 5, 6).and_hms(7, 8, 9).offset() != EST); } + + #[test] + fn test_datetime_fmt_with_local() { + // if we are not around the year boundary, local and UTC date should have the same year + let dt = Local::now().with_month(5).unwrap(); + assert_eq!(dt.format("%Y").to_string(), dt.with_offset(UTC).format("%Y").to_string()); + } } diff --git a/src/lib.rs b/src/lib.rs index dc62965..9b9a983 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ /*! -# Chrono 0.1.13 +# Chrono 0.1.14 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. diff --git a/src/offset.rs b/src/offset.rs index cbdc1ca..61bcb8c 100644 --- a/src/offset.rs +++ b/src/offset.rs @@ -541,3 +541,8 @@ impl fmt::Show for Local { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.cached.fmt(f) } } +impl fmt::String for Local { + // TODO this should be a tz name whenever available + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.cached.fmt(f) } +} +