0.2.9: language changes.
- `std::num::Int` is deprecated. - Removed one feature flag (`str_char`).
This commit is contained in:
parent
e012702033
commit
9ed34ec542
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
version = "0.2.8"
|
version = "0.2.9"
|
||||||
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"
|
||||||
|
@ -15,5 +15,5 @@ license = "MIT/Apache-2.0"
|
||||||
name = "chrono"
|
name = "chrono"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
time = "0.1.22"
|
time = "*"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[Chrono][doc] 0.2.8
|
[Chrono][doc] 0.2.9
|
||||||
===================
|
===================
|
||||||
|
|
||||||
[![Chrono on Travis CI][travis-image]][travis]
|
[![Chrono on Travis CI][travis-image]][travis]
|
||||||
|
|
22
src/div.rs
22
src/div.rs
|
@ -8,31 +8,39 @@
|
||||||
// Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
|
// Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
|
||||||
// December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
|
// December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
|
||||||
|
|
||||||
use std::num::Int;
|
use std::ops::{Add, Sub, Div, Rem};
|
||||||
|
use std::num::{Zero, One};
|
||||||
|
|
||||||
/// Same as `(a / b, a % b)`.
|
/// Same as `(a / b, a % b)`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn div_rem<T: Int>(a: T, b: T) -> (T, T) {
|
pub fn div_rem<T>(a: T, b: T) -> (T, T)
|
||||||
|
where T: Copy + Div<T,Output=T> + Rem<T,Output=T> {
|
||||||
(a / b, a % b)
|
(a / b, a % b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates a floored integer quotient.
|
/// Calculates a floored integer quotient.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn div_floor<T: Int>(a: T, b: T) -> T {
|
pub fn div_floor<T>(a: T, b: T) -> T
|
||||||
|
where T: Copy + Ord + Zero + One +
|
||||||
|
Add<T,Output=T> + Sub<T,Output=T> + Div<T,Output=T> + Rem<T,Output=T> {
|
||||||
div_mod_floor(a, b).0
|
div_mod_floor(a, b).0
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates a floored modulo.
|
/// Calculates a floored modulo.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn mod_floor<T: Int>(a: T, b: T) -> T {
|
pub fn mod_floor<T>(a: T, b: T) -> T
|
||||||
|
where T: Copy + Ord + Zero + One +
|
||||||
|
Add<T,Output=T> + Sub<T,Output=T> + Div<T,Output=T> + Rem<T,Output=T> {
|
||||||
div_mod_floor(a, b).1
|
div_mod_floor(a, b).1
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calculates a floored integer quotient and modulo.
|
/// Calculates a floored integer quotient and modulo.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn div_mod_floor<T: Int>(a: T, b: T) -> (T, T) {
|
pub fn div_mod_floor<T>(a: T, b: T) -> (T, T)
|
||||||
let zero = Int::zero();
|
where T: Copy + Ord + Zero + One +
|
||||||
let one = Int::one();
|
Add<T,Output=T> + Sub<T,Output=T> + Div<T,Output=T> + Rem<T,Output=T> {
|
||||||
|
let zero = Zero::zero();
|
||||||
|
let one = One::one();
|
||||||
match (a / b, a % b) {
|
match (a / b, a % b) {
|
||||||
(d, r) if (r > zero && b < zero) || (r < zero && b > zero) => (d - one, r + b),
|
(d, r) if (r > zero && b < zero) || (r < zero && b > zero) => (d - one, r + b),
|
||||||
(d, r) => (d, r),
|
(d, r) => (d, r),
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::usize;
|
use std::usize;
|
||||||
use std::num::Int;
|
|
||||||
|
|
||||||
use Weekday;
|
use Weekday;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::num::Int;
|
|
||||||
|
|
||||||
use Weekday;
|
use Weekday;
|
||||||
use super::{ParseResult, TOO_SHORT, INVALID, OUT_OF_RANGE};
|
use super::{ParseResult, TOO_SHORT, INVALID, OUT_OF_RANGE};
|
||||||
|
|
|
@ -134,19 +134,19 @@ impl<'a> Iterator for StrftimeItems<'a> {
|
||||||
return Some(item);
|
return Some(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.remainder.slice_shift_char() {
|
match self.remainder.chars().next() {
|
||||||
// we are done
|
// we are done
|
||||||
None => return None,
|
None => return None,
|
||||||
|
|
||||||
// the next item is a specifier
|
// the next item is a specifier
|
||||||
Some(('%', remainder)) => {
|
Some('%') => {
|
||||||
self.remainder = remainder;
|
self.remainder = &self.remainder[1..];
|
||||||
|
|
||||||
let (spec, remainder) = match self.remainder.slice_shift_char() {
|
let spec = match self.remainder.chars().next() {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => return Some(Item::Error), // premature end of string
|
None => return Some(Item::Error), // premature end of string
|
||||||
};
|
};
|
||||||
self.remainder = remainder;
|
self.remainder = &self.remainder[spec.len_utf8()..];
|
||||||
|
|
||||||
macro_rules! recons {
|
macro_rules! recons {
|
||||||
[$head:expr, $($tail:expr),+] => ({
|
[$head:expr, $($tail:expr),+] => ({
|
||||||
|
@ -216,7 +216,7 @@ impl<'a> Iterator for StrftimeItems<'a> {
|
||||||
},
|
},
|
||||||
|
|
||||||
// the next item is space
|
// the next item is space
|
||||||
Some((c, _)) if c.is_whitespace() => {
|
Some(c) if c.is_whitespace() => {
|
||||||
// `%` is not a whitespace, so `c != '%'` is redundant
|
// `%` is not a whitespace, so `c != '%'` is redundant
|
||||||
let nextspec = self.remainder.find(|c: char| !c.is_whitespace())
|
let nextspec = self.remainder.find(|c: char| !c.is_whitespace())
|
||||||
.unwrap_or(self.remainder.len());
|
.unwrap_or(self.remainder.len());
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
# Chrono 0.2.8
|
# Chrono 0.2.9
|
||||||
|
|
||||||
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.
|
||||||
|
@ -268,7 +268,7 @@ Advanced time zone handling is not yet supported (but is planned in 0.3).
|
||||||
#![doc(html_root_url = "https://lifthrasiir.github.io/rust-chrono/")]
|
#![doc(html_root_url = "https://lifthrasiir.github.io/rust-chrono/")]
|
||||||
|
|
||||||
#![feature(slice_patterns)]
|
#![feature(slice_patterns)]
|
||||||
#![feature(core, str_char, std_misc)] // lib stability features as per RFC #507
|
#![feature(core, std_misc, zero_one)] // lib stability features as per RFC #507
|
||||||
#![cfg_attr(test, feature(test))] // ditto
|
#![cfg_attr(test, feature(test))] // ditto
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use std::{str, fmt, hash};
|
use std::{str, fmt, hash};
|
||||||
use std::num::Int;
|
|
||||||
use std::ops::{Add, Sub};
|
use std::ops::{Add, Sub};
|
||||||
|
|
||||||
use Timelike;
|
use Timelike;
|
||||||
|
|
Loading…
Reference in New Issue