Skip to content

Commit

Permalink
upgrade to chrono 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
djzin committed Feb 11, 2017
1 parent 3261d62 commit 9e3c718
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chrono-tz"
version = "0.2.5"
version = "0.3.0"
authors = ["Djzin"]
build = "build.rs"
description = "TimeZone implementations for rust-chrono from the IANA database"
Expand All @@ -11,7 +11,7 @@ readme = "README.md"
license = "MIT/Apache-2.0"

[dependencies]
chrono = "0.2"
chrono = "0.3"

[build-dependencies]
parse-zoneinfo = "0.1"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Chrono-TZ 0.2.5
# Chrono-TZ 0.3.0

`Chrono-TZ` is a library that provides implementors of the
[`TimeZone`][timezone] trait for [`rust-chrono`][chrono]. The
Expand All @@ -22,8 +22,8 @@ Put this in your `Cargo.toml`:

```toml
[dependencies]
chrono = "0.2"
chrono-tz = "0.2"
chrono = "0.3"
chrono-tz = "0.3"
```

Then you will need to write (in your crate root):
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! # Chrono-TZ 0.2.5
//! # Chrono-TZ 0.3.0
//!
//! `Chrono-TZ` is a library that provides implementors of the
//! [`TimeZone`][timezone] trait for [`rust-chrono`][chrono]. The
Expand All @@ -16,8 +16,8 @@
//!
//! ```toml
//! [dependencies]
//! chrono = "0.2"
//! chrono-tz = "0.2"
//! chrono = "0.3"
//! chrono-tz = "0.3"
//! ```
//!
//! Then you will need to write (in your crate root):
Expand Down
20 changes: 10 additions & 10 deletions src/timezone_impl.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use chrono::{Offset, TimeZone, NaiveDate, NaiveDateTime, LocalResult, Duration};
use chrono::{Offset, TimeZone, NaiveDate, NaiveDateTime, LocalResult, FixedOffset};
use std::fmt::{Debug, Display, Formatter, Error};
use std::cmp::Ordering;
use binary_search::binary_search;
use super::timezones::Tz;

#[derive(Copy, Clone, PartialEq, Eq)]
pub struct FixedTimespan {
pub utc_offset: i64,
pub dst_offset: i64,
pub utc_offset: i32,
pub dst_offset: i32,
pub name: &'static str,
}

impl Offset for FixedTimespan {
fn local_minus_utc(&self) -> Duration {
Duration::seconds(self.utc_offset + self.dst_offset)
fn fix(&self) -> FixedOffset {
FixedOffset::east(self.utc_offset + self.dst_offset)
}
}

Expand Down Expand Up @@ -53,8 +53,8 @@ impl TzOffset {
}

impl Offset for TzOffset {
fn local_minus_utc(&self) -> Duration {
self.offset.local_minus_utc()
fn fix(&self) -> FixedOffset {
self.offset.fix()
}
}

Expand Down Expand Up @@ -143,14 +143,14 @@ impl FixedTimespanSet {
None
} else {
let span = self.rest[index - 1];
Some(span.0 + span.1.utc_offset + span.1.dst_offset)
Some(span.0 + span.1.utc_offset as i64 + span.1.dst_offset as i64)
},
end: if index == self.rest.len() {
None
} else if index == 0 {
Some(self.rest[index].0 + self.first.utc_offset + self.first.dst_offset)
Some(self.rest[index].0 + self.first.utc_offset as i64 + self.first.dst_offset as i64)
} else {
Some(self.rest[index].0 + self.rest[index - 1].1.utc_offset + self.rest[index - 1].1.dst_offset)
Some(self.rest[index].0 + self.rest[index - 1].1.utc_offset as i64 + self.rest[index - 1].1.dst_offset as i64)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/numberphile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use chrono_tz::Asia::Gaza;
use chrono_tz::Europe::Moscow;

fn seconds<Tz1: TimeZone, Tz2: TimeZone>(from: DateTime<Tz1>, to: DateTime<Tz2>) -> i64 {
(to - from).num_seconds()
to.signed_duration_since(from).num_seconds()
}

#[test]
Expand Down Expand Up @@ -135,9 +135,7 @@ fn london_25_march() {
assert_eq!(seconds(from, to), 60 * 60 * 24);
}

// FIXME doesn't currently work!
#[test]
#[ignore]
fn leapsecond() {
let from = UTC.ymd(2016, 6, 30).and_hms(23, 59, 59);
let to = UTC.ymd(2016, 6, 30).and_hms_milli(23, 59, 59, 1000);
Expand All @@ -153,7 +151,9 @@ fn leapsecond_2() {
assert_eq!(seconds(from, to), 2);
}

// FIXME doesn't currently work!
#[test]
#[ignore]
fn leapsecond_3() {
let from = UTC.ymd(2016, 6, 30).and_hms_milli(23, 59, 59, 1000);
let to = UTC.ymd(2016, 7, 1).and_hms(0, 0, 0);
Expand Down

0 comments on commit 9e3c718

Please sign in to comment.