0.2.7: language changes.

- Feature flags are now required on the doctests.

- New lints for trivial casts. We are now not going to change
  the internal implementation type for `NaiveDate`, so that's fine.
This commit is contained in:
Kang Seonghoon 2015-03-27 11:35:34 +09:00
parent a5bd6c040e
commit 98c5f3a2b1
5 changed files with 17 additions and 16 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "chrono"
version = "0.2.6"
version = "0.2.7"
authors = ["Kang Seonghoon <public+rust@mearie.org>"]
description = "Date and time library for Rust"
@ -15,5 +15,5 @@ license = "MIT/Apache-2.0"
name = "chrono"
[dependencies]
time = "0.1.20"
time = "0.1.21"

View File

@ -1,4 +1,4 @@
[Chrono][doc] 0.2.6
[Chrono][doc] 0.2.7
===================
[![Chrono on Travis CI][travis-image]][travis]

View File

@ -723,11 +723,11 @@ mod tests {
assert_eq!(parse!(year_div_100: -1, year_mod_100: 42, month: 1, day: 1),
Err(OUT_OF_RANGE));
let max_year = date::MAX.year();
assert_eq!(parse!(year_div_100: max_year as i32 / 100,
year_mod_100: max_year as i32 % 100, month: 1, day: 1),
assert_eq!(parse!(year_div_100: max_year / 100,
year_mod_100: max_year % 100, month: 1, day: 1),
ymd(max_year, 1, 1));
assert_eq!(parse!(year_div_100: (max_year + 1) as i32 / 100,
year_mod_100: (max_year + 1) as i32 % 100, month: 1, day: 1),
assert_eq!(parse!(year_div_100: (max_year + 1) / 100,
year_mod_100: (max_year + 1) % 100, month: 1, day: 1),
Err(OUT_OF_RANGE));
// ymd: conflicting inputs

View File

@ -4,7 +4,7 @@
/*!
# Chrono 0.2.6
# Chrono 0.2.7
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.
@ -100,6 +100,7 @@ Addition and subtraction is also supported.
The following illustrates most supported operations to the date and time:
~~~~ {.rust}
# #![feature(std_misc)]
use chrono::*;
# /* we intentionally fake the datetime...
@ -270,7 +271,7 @@ Advanced time zone handling is not yet supported (but is planned in 0.3).
#![cfg_attr(test, feature(test))] // ditto
#![deny(missing_docs)]
extern crate "time" as stdtime;
extern crate time as stdtime;
pub use duration::Duration;
pub use offset::{TimeZone, Offset, LocalResult};

View File

@ -20,8 +20,8 @@ use format::{parse, Parsed, ParseError, ParseResult, DelayedFormat, StrftimeItem
use self::internals::{DateImpl, Of, Mdf, YearFlags};
const MAX_YEAR: i32 = internals::MAX_YEAR as i32;
const MIN_YEAR: i32 = internals::MIN_YEAR as i32;
const MAX_YEAR: i32 = internals::MAX_YEAR;
const MIN_YEAR: i32 = internals::MIN_YEAR;
// MAX_YEAR-12-31 minus 0000-01-01
// = ((MAX_YEAR+1)-01-01 minus 0001-01-01) + (0001-01-01 minus 0000-01-01) - 1 day
@ -74,7 +74,7 @@ impl NaiveDate {
fn from_of(year: i32, of: Of) -> Option<NaiveDate> {
if year >= MIN_YEAR && year <= MAX_YEAR && of.valid() {
let Of(of) = of;
Some(NaiveDate { ymdf: ((year << 13) as DateImpl) | (of as DateImpl) })
Some(NaiveDate { ymdf: (year << 13) | (of as DateImpl) })
} else {
None
}
@ -452,7 +452,7 @@ impl NaiveDate {
}
impl Datelike for NaiveDate {
#[inline] fn year(&self) -> i32 { (self.ymdf >> 13) as i32 }
#[inline] fn year(&self) -> i32 { self.ymdf >> 13 }
#[inline] fn month(&self) -> u32 { self.mdf().month() }
#[inline] fn month0(&self) -> u32 { self.mdf().month() - 1 }
#[inline] fn day(&self) -> u32 { self.mdf().day() }
@ -1326,7 +1326,7 @@ mod internals {
#[inline]
pub fn ordinal(&self) -> u32 {
let Of(of) = *self;
(of >> 4) as u32
of >> 4
}
#[inline]
@ -1436,7 +1436,7 @@ mod internals {
#[inline]
pub fn month(&self) -> u32 {
let Mdf(mdf) = *self;
(mdf >> 9) as u32
mdf >> 9
}
#[inline]
@ -1449,7 +1449,7 @@ mod internals {
#[inline]
pub fn day(&self) -> u32 {
let Mdf(mdf) = *self;
((mdf >> 4) & 0b11111) as u32
(mdf >> 4) & 0b11111
}
#[inline]