0.1.14: fixed a missing `String` impl for `Local`.

Fixes #20. Thanks to @daboross.
This commit is contained in:
Kang Seonghoon 2015-01-10 12:25:08 +09:00
parent ca84749869
commit 45765ebd13
4 changed files with 16 additions and 3 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "chrono" name = "chrono"
version = "0.1.13" version = "0.1.14"
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"

View File

@ -221,8 +221,9 @@ impl<Off: Offset + fmt::String> fmt::String for DateTime<Off> {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use {Datelike};
use duration::Duration; use duration::Duration;
use offset::{Offset, UTC, FixedOffset}; use offset::{Offset, UTC, Local, FixedOffset};
#[test] #[test]
#[allow(non_snake_case)] #[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_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); 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());
}
} }

View File

@ -4,7 +4,7 @@
/*! /*!
# Chrono 0.1.13 # Chrono 0.1.14
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.

View File

@ -541,3 +541,8 @@ impl fmt::Show for Local {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.cached.fmt(f) } 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) }
}