Merge branch 'master' into feature_clock
This commit is contained in:
commit
a9618c8e9d
|
@ -8,6 +8,12 @@ Chrono obeys the principle of [Semantic Versioning](http://semver.org/).
|
||||||
There were/are numerous minor versions before 1.0 due to the language changes.
|
There were/are numerous minor versions before 1.0 due to the language changes.
|
||||||
Versions with only mechnical changes will be omitted from the following list.
|
Versions with only mechnical changes will be omitted from the following list.
|
||||||
|
|
||||||
|
## 0.4.next
|
||||||
|
|
||||||
|
* More strongly deprecate RustcSerialize: remove it from documentation unless
|
||||||
|
the feature is enabled, issue a deprecation warning if the rustc-serialize
|
||||||
|
feature is enabled (@quodlibetor)
|
||||||
|
|
||||||
## 0.4.1
|
## 0.4.1
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
22
README.md
22
README.md
|
@ -1,5 +1,5 @@
|
||||||
[Chrono][docsrs] 0.4.0
|
[Chrono][docsrs]: Date and Time for Rust
|
||||||
======================
|
========================================
|
||||||
|
|
||||||
[![Chrono on Travis CI][travis-image]][travis]
|
[![Chrono on Travis CI][travis-image]][travis]
|
||||||
[![Chrono on Appveyor][appveyor-image]][appveyor]
|
[![Chrono on Appveyor][appveyor-image]][appveyor]
|
||||||
|
@ -12,9 +12,8 @@
|
||||||
[appveyor]: https://ci.appveyor.com/project/chronotope/chrono
|
[appveyor]: https://ci.appveyor.com/project/chronotope/chrono
|
||||||
[cratesio-image]: https://img.shields.io/crates/v/chrono.svg
|
[cratesio-image]: https://img.shields.io/crates/v/chrono.svg
|
||||||
[cratesio]: https://crates.io/crates/chrono
|
[cratesio]: https://crates.io/crates/chrono
|
||||||
[docsrs-image]: https://docs.rs/chrono/badge.svg?version=0.4.0
|
[docsrs-image]: https://docs.rs/chrono/badge.svg
|
||||||
[docsrs]: https://docs.rs/chrono/0.4.0/
|
[docsrs]: https://docs.rs/chrono
|
||||||
|
|
||||||
|
|
||||||
Date and time handling for Rust.
|
Date and time handling for Rust.
|
||||||
It aims to be a feature-complete superset of
|
It aims to be a feature-complete superset of
|
||||||
|
@ -46,21 +45,14 @@ Put this in your `Cargo.toml`:
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
```
|
```
|
||||||
|
|
||||||
Or, if you want [Serde](https://github.com/serde-rs/serde) or
|
Or, if you want [Serde](https://github.com/serde-rs/serde) include the feature
|
||||||
[rustc-serialize](https://github.com/rust-lang-nursery/rustc-serialize) support,
|
like this:
|
||||||
include the features like this:
|
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = { version = "0.4", features = ["serde", "rustc-serialize"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
```
|
```
|
||||||
|
|
||||||
> Note that Chrono's support for rustc-serialize is now considered deprecated.
|
|
||||||
Starting from 0.4.0 there is no further guarantee that
|
|
||||||
the features available in Serde will be also available to rustc-serialize,
|
|
||||||
and the support can be removed in any future major version.
|
|
||||||
**Rustc-serialize users are strongly recommended to migrate to Serde.**
|
|
||||||
|
|
||||||
Then put this in your crate root:
|
Then put this in your crate root:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
|
|
@ -701,7 +701,9 @@ pub mod rustc_serialize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl Decodable for TsSeconds<FixedOffset> {
|
impl Decodable for TsSeconds<FixedOffset> {
|
||||||
|
#[allow(deprecated)]
|
||||||
fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds<FixedOffset>, D::Error> {
|
fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds<FixedOffset>, D::Error> {
|
||||||
from(FixedOffset::east(0).timestamp_opt(d.read_i64()?, 0), d)
|
from(FixedOffset::east(0).timestamp_opt(d.read_i64()?, 0), d)
|
||||||
.map(TsSeconds)
|
.map(TsSeconds)
|
||||||
|
@ -723,13 +725,16 @@ pub mod rustc_serialize {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TsSeconds<Tz: TimeZone>(DateTime<Tz>);
|
pub struct TsSeconds<Tz: TimeZone>(DateTime<Tz>);
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl<Tz: TimeZone> From<TsSeconds<Tz>> for DateTime<Tz> {
|
impl<Tz: TimeZone> From<TsSeconds<Tz>> for DateTime<Tz> {
|
||||||
/// Pull the inner DateTime<Tz> out
|
/// Pull the inner DateTime<Tz> out
|
||||||
|
#[allow(deprecated)]
|
||||||
fn from(obj: TsSeconds<Tz>) -> DateTime<Tz> {
|
fn from(obj: TsSeconds<Tz>) -> DateTime<Tz> {
|
||||||
obj.0
|
obj.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl<Tz: TimeZone> Deref for TsSeconds<Tz> {
|
impl<Tz: TimeZone> Deref for TsSeconds<Tz> {
|
||||||
type Target = DateTime<Tz>;
|
type Target = DateTime<Tz>;
|
||||||
|
|
||||||
|
@ -738,6 +743,7 @@ pub mod rustc_serialize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl Decodable for TsSeconds<Utc> {
|
impl Decodable for TsSeconds<Utc> {
|
||||||
fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds<Utc>, D::Error> {
|
fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds<Utc>, D::Error> {
|
||||||
from(Utc.timestamp_opt(d.read_i64()?, 0), d)
|
from(Utc.timestamp_opt(d.read_i64()?, 0), d)
|
||||||
|
@ -756,7 +762,9 @@ pub mod rustc_serialize {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature="clock")]
|
#[cfg(feature="clock")]
|
||||||
|
#[allow(deprecated)]
|
||||||
impl Decodable for TsSeconds<Local> {
|
impl Decodable for TsSeconds<Local> {
|
||||||
|
#[allow(deprecated)]
|
||||||
fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds<Local>, D::Error> {
|
fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds<Local>, D::Error> {
|
||||||
from(Utc.timestamp_opt(d.read_i64()?, 0), d)
|
from(Utc.timestamp_opt(d.read_i64()?, 0), d)
|
||||||
.map(|dt| TsSeconds(dt.with_timezone(&Local)))
|
.map(|dt| TsSeconds(dt.with_timezone(&Local)))
|
||||||
|
|
|
@ -269,8 +269,6 @@ macro_rules! fix { ($x:ident) => (Item::Fixed(Fixed::$x)) }
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
||||||
pub struct ParseError(ParseErrorKind);
|
pub struct ParseError(ParseErrorKind);
|
||||||
|
|
||||||
// clippy false positive https://github.com/rust-lang-nursery/rust-clippy/issues/2475
|
|
||||||
#[cfg_attr(feature = "cargo-clippy", allow(empty_line_after_outer_attr))]
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
||||||
enum ParseErrorKind {
|
enum ParseErrorKind {
|
||||||
/// Given field is out of permitted range.
|
/// Given field is out of permitted range.
|
||||||
|
|
|
@ -414,7 +414,8 @@ pub use oldtime::Duration;
|
||||||
#[doc(no_inline)] pub use naive::{NaiveDate, IsoWeek, NaiveTime, NaiveDateTime};
|
#[doc(no_inline)] pub use naive::{NaiveDate, IsoWeek, NaiveTime, NaiveDateTime};
|
||||||
pub use date::{Date, MIN_DATE, MAX_DATE};
|
pub use date::{Date, MIN_DATE, MAX_DATE};
|
||||||
pub use datetime::{DateTime, SecondsFormat};
|
pub use datetime::{DateTime, SecondsFormat};
|
||||||
#[cfg(feature = "rustc-serialize")] pub use datetime::rustc_serialize::TsSeconds;
|
#[cfg(feature = "rustc-serialize")]
|
||||||
|
pub use datetime::rustc_serialize::TsSeconds;
|
||||||
pub use format::{ParseError, ParseResult};
|
pub use format::{ParseError, ParseResult};
|
||||||
pub use round::SubsecRound;
|
pub use round::SubsecRound;
|
||||||
|
|
||||||
|
@ -458,6 +459,7 @@ pub mod naive {
|
||||||
pub use self::time::NaiveTime;
|
pub use self::time::NaiveTime;
|
||||||
pub use self::datetime::NaiveDateTime;
|
pub use self::datetime::NaiveDateTime;
|
||||||
#[cfg(feature = "rustc-serialize")]
|
#[cfg(feature = "rustc-serialize")]
|
||||||
|
#[allow(deprecated)]
|
||||||
pub use self::datetime::rustc_serialize::TsSeconds;
|
pub use self::datetime::rustc_serialize::TsSeconds;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1503,24 +1503,32 @@ pub mod rustc_serialize {
|
||||||
|
|
||||||
/// A `DateTime` that can be deserialized from a seconds-based timestamp
|
/// A `DateTime` that can be deserialized from a seconds-based timestamp
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
#[deprecated(since = "1.4.2",
|
||||||
|
note = "RustcSerialize will be removed before chrono 1.0, use Serde instead")]
|
||||||
pub struct TsSeconds(NaiveDateTime);
|
pub struct TsSeconds(NaiveDateTime);
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl From<TsSeconds> for NaiveDateTime {
|
impl From<TsSeconds> for NaiveDateTime {
|
||||||
/// Pull the internal NaiveDateTime out
|
/// Pull the internal NaiveDateTime out
|
||||||
|
#[allow(deprecated)]
|
||||||
fn from(obj: TsSeconds) -> NaiveDateTime {
|
fn from(obj: TsSeconds) -> NaiveDateTime {
|
||||||
obj.0
|
obj.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl Deref for TsSeconds {
|
impl Deref for TsSeconds {
|
||||||
type Target = NaiveDateTime;
|
type Target = NaiveDateTime;
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&self.0
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(deprecated)]
|
||||||
impl Decodable for TsSeconds {
|
impl Decodable for TsSeconds {
|
||||||
|
#[allow(deprecated)]
|
||||||
fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds, D::Error> {
|
fn decode<D: Decoder>(d: &mut D) -> Result<TsSeconds, D::Error> {
|
||||||
Ok(TsSeconds(
|
Ok(TsSeconds(
|
||||||
NaiveDateTime::from_timestamp_opt(d.read_i64()?, 0)
|
NaiveDateTime::from_timestamp_opt(d.read_i64()?, 0)
|
||||||
|
|
Loading…
Reference in New Issue