Update to 2018 edition (and MSRV 1.32)

This commit is contained in:
Dirkjan Ochtman 2022-03-06 14:06:07 +01:00
parent 895906a810
commit e4c8a529f5
22 changed files with 178 additions and 177 deletions

View File

@ -31,10 +31,11 @@ jobs:
- os: ubuntu-latest
rust_version: nightly
- os: ubuntu-18.04
rust_version: 1.13.0
rust_version: 1.32.0
- os: macos-latest
rust_version: 1.13.0
# time doesn't work on windows with 1.13
rust_version: 1.32.0
- os: windows-latest
rust_version: 1.32.0
runs-on: ${{ matrix.os }}

View File

@ -39,10 +39,11 @@ jobs:
- os: ubuntu-latest
rust_version: nightly
- os: ubuntu-18.04
rust_version: 1.13.0
rust_version: 1.32.0
- os: macos-latest
rust_version: 1.13.0
# time doesn't work on windows with 1.13
rust_version: 1.32.0
- os: windows-latest
rust_version: 1.32.0
runs-on: ${{ matrix.os }}

View File

@ -15,6 +15,7 @@ categories = ["date-and-time"]
readme = "README.md"
license = "MIT/Apache-2.0"
exclude = ["/ci/*", "/.travis.yml", "/appveyor.yml", "/Makefile"]
edition = "2018"
[badges]
travis-ci = { repository = "chronotope/chrono" }

View File

@ -8,7 +8,7 @@ source "${BASH_SOURCE[0]%/*}/_shlib.sh"
TEST_TZS=(ACST-9:30 EST4 UTC0 Asia/Katmandu)
FEATURES=(std serde clock "alloc serde" unstable-locales)
CHECK_FEATURES=(alloc "std unstable-locales" "serde clock" "clock unstable-locales")
RUST_113_FEATURES=(rustc-serialize serde)
RUST_132_FEATURES=(rustc-serialize serde)
main() {
if [[ "$*" =~ "-h" ]]; then
@ -29,7 +29,7 @@ meaningful in the github actions feature matrix UI.
runv cargo --version
if [[ ${RUST_VERSION:-} != 1.13.0 ]]; then
if [[ ${RUST_VERSION:-} != 1.32.0 ]]; then
if [[ ${WASM:-} == yes_wasm ]]; then
test_wasm
elif [[ ${WASM:-} == wasm_simple ]]; then
@ -43,8 +43,8 @@ meaningful in the github actions feature matrix UI.
else
test_regular UTC0
fi
elif [[ ${RUST_VERSION:-} == 1.13.0 ]]; then
test_113
elif [[ ${RUST_VERSION:-} == 1.32.0 ]]; then
test_132
else
echo "ERROR: didn't run any tests"
exit 1
@ -74,9 +74,9 @@ check_combinatoric() {
done
}
test_113() {
test_132() {
runv cargo build --color=always
for feature in "${RUST_113_FEATURES[@]}"; do
for feature in "${RUST_132_FEATURES[@]}"; do
runt cargo build --features "$feature" --color=always
done
}

View File

@ -3,21 +3,21 @@
//! ISO 8601 calendar date with time zone.
use crate::oldtime::Duration as OldDuration;
#[cfg(any(feature = "alloc", feature = "std", test))]
use core::borrow::Borrow;
use core::cmp::Ordering;
use core::ops::{Add, Sub};
use core::{fmt, hash};
use oldtime::Duration as OldDuration;
#[cfg(feature = "unstable-locales")]
use format::Locale;
use crate::format::Locale;
#[cfg(any(feature = "alloc", feature = "std", test))]
use format::{DelayedFormat, Item, StrftimeItems};
use naive::{self, IsoWeek, NaiveDate, NaiveTime};
use offset::{TimeZone, Utc};
use DateTime;
use {Datelike, Weekday};
use crate::format::{DelayedFormat, Item, StrftimeItems};
use crate::naive::{self, IsoWeek, NaiveDate, NaiveTime};
use crate::offset::{TimeZone, Utc};
use crate::DateTime;
use crate::{Datelike, Weekday};
/// ISO 8601 calendar date with time zone.
///
@ -36,7 +36,7 @@ use {Datelike, Weekday};
/// the corresponding local date should exist for at least a moment.
/// (It may still have a gap from the offset changes.)
///
/// - The `TimeZone` is free to assign *any* [`Offset`](::offset::Offset) to the
/// - The `TimeZone` is free to assign *any* [`Offset`](crate::offset::Offset) to the
/// local date, as long as that offset did occur in given day.
///
/// For example, if `2015-03-08T01:59-08:00` is followed by `2015-03-08T03:00-07:00`,
@ -297,7 +297,7 @@ where
}
/// Formats the date with the specified format string.
/// See the [`::format::strftime`] module
/// See the [`crate::format::strftime`] module
/// on the supported escape sequences.
///
/// # Example

View File

@ -3,10 +3,10 @@
//! ISO 8601 date and time with time zone.
use crate::oldtime::Duration as OldDuration;
use core::cmp::Ordering;
use core::ops::{Add, Sub};
use core::{fmt, hash, str};
use oldtime::Duration as OldDuration;
#[cfg(any(feature = "std", test))]
use std::time::{SystemTime, UNIX_EPOCH};
@ -16,19 +16,19 @@ use alloc::string::{String, ToString};
use std::string::ToString;
#[cfg(any(feature = "alloc", feature = "std", test))]
use core::borrow::Borrow;
#[cfg(any(feature = "alloc", feature = "std", test))]
use format::DelayedFormat;
use crate::format::DelayedFormat;
#[cfg(feature = "unstable-locales")]
use format::Locale;
use format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
use format::{Fixed, Item};
use naive::{self, IsoWeek, NaiveDate, NaiveDateTime, NaiveTime};
use crate::format::Locale;
use crate::format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
use crate::format::{Fixed, Item};
use crate::naive::{self, IsoWeek, NaiveDate, NaiveDateTime, NaiveTime};
#[cfg(feature = "clock")]
use offset::Local;
use offset::{FixedOffset, Offset, TimeZone, Utc};
use Date;
use {Datelike, Timelike, Weekday};
use crate::offset::Local;
use crate::offset::{FixedOffset, Offset, TimeZone, Utc};
use crate::Date;
use crate::{Datelike, Timelike, Weekday};
#[cfg(any(feature = "alloc", feature = "std", test))]
use core::borrow::Borrow;
/// Specific formatting options for seconds. This may be extended in the
/// future, so exhaustive matching in external code is not recommended.
@ -473,7 +473,7 @@ impl DateTime<FixedOffset> {
/// Parses a string with the specified format string and returns a new
/// [`DateTime`] with a parsed [`FixedOffset`].
///
/// See the [`::format::strftime`] module on the supported escape
/// See the [`crate::format::strftime`] module on the supported escape
/// sequences.
///
/// See also [`TimeZone::datetime_from_str`] which gives a local
@ -543,9 +543,9 @@ where
/// ```
#[cfg(any(feature = "alloc", feature = "std", test))]
pub fn to_rfc3339_opts(&self, secform: SecondsFormat, use_z: bool) -> String {
use format::Numeric::*;
use format::Pad::Zero;
use SecondsFormat::*;
use crate::format::Numeric::*;
use crate::format::Pad::Zero;
use crate::SecondsFormat::*;
debug_assert!(secform != __NonExhaustive, "Do not use __NonExhaustive!");
@ -597,7 +597,7 @@ where
}
/// Formats the combined date and time with the specified format string.
/// See the [`::format::strftime`] module
/// See the [`crate::format::strftime`] module
/// on the supported escape sequences.
///
/// # Example
@ -1084,11 +1084,11 @@ fn test_decodable_json_timestamps<FUtc, FFixed, FLocal, E>(
#[cfg(feature = "rustc-serialize")]
pub mod rustc_serialize {
use super::DateTime;
#[cfg(feature = "clock")]
use crate::offset::Local;
use crate::offset::{FixedOffset, LocalResult, TimeZone, Utc};
use core::fmt;
use core::ops::Deref;
#[cfg(feature = "clock")]
use offset::Local;
use offset::{FixedOffset, LocalResult, TimeZone, Utc};
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
impl<Tz: TimeZone> Encodable for DateTime<Tz> {
@ -1211,12 +1211,12 @@ pub mod rustc_serialize {
#[cfg(feature = "serde")]
pub mod serde {
use super::DateTime;
use core::fmt;
#[cfg(feature = "clock")]
use offset::Local;
use offset::{FixedOffset, LocalResult, TimeZone, Utc};
use serdelib::{de, ser};
use {ne_timestamp, SerdeError};
use crate::offset::Local;
use crate::offset::{FixedOffset, LocalResult, TimeZone, Utc};
use crate::serdelib::{de, ser};
use crate::{ne_timestamp, SerdeError};
use core::fmt;
#[doc(hidden)]
#[derive(Debug)]
@ -1379,8 +1379,8 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use offset::TimeZone;
use {DateTime, Utc};
use crate::offset::TimeZone;
use crate::{DateTime, Utc};
use super::{serde_from, NanoSecondsTimestampVisitor};
@ -1532,7 +1532,7 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use {DateTime, Utc};
use crate::{DateTime, Utc};
use super::NanoSecondsTimestampVisitor;
@ -1689,8 +1689,8 @@ pub mod serde {
use serdelib::{de, ser};
use offset::TimeZone;
use {DateTime, Utc};
use crate::offset::TimeZone;
use crate::{DateTime, Utc};
use super::{serde_from, MicroSecondsTimestampVisitor};
@ -1842,7 +1842,7 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use {DateTime, Utc};
use crate::{DateTime, Utc};
use super::MicroSecondsTimestampVisitor;
@ -1998,8 +1998,8 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use offset::TimeZone;
use {DateTime, Utc};
use crate::offset::TimeZone;
use crate::{DateTime, Utc};
use super::{serde_from, MilliSecondsTimestampVisitor};
@ -2148,7 +2148,7 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use {DateTime, Utc};
use crate::{DateTime, Utc};
use super::MilliSecondsTimestampVisitor;
@ -2317,8 +2317,8 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use offset::TimeZone;
use {DateTime, Utc};
use crate::offset::TimeZone;
use crate::{DateTime, Utc};
use super::{serde_from, SecondsTimestampVisitor};
@ -2461,7 +2461,7 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use {DateTime, Utc};
use crate::{DateTime, Utc};
use super::SecondsTimestampVisitor;
@ -2614,14 +2614,14 @@ pub mod serde {
#[cfg(test)]
mod tests {
use super::DateTime;
use naive::{NaiveDate, NaiveTime};
use crate::naive::{NaiveDate, NaiveTime};
#[cfg(feature = "clock")]
use offset::Local;
use offset::{FixedOffset, TimeZone, Utc};
use oldtime::Duration;
use crate::offset::Local;
use crate::offset::{FixedOffset, TimeZone, Utc};
use crate::oldtime::Duration;
#[cfg(feature = "clock")]
use crate::Datelike;
use std::time::{SystemTime, UNIX_EPOCH};
#[cfg(feature = "clock")]
use Datelike;
#[test]
#[allow(non_snake_case)]
@ -2774,7 +2774,7 @@ mod tests {
#[test]
fn test_rfc3339_opts() {
use SecondsFormat::*;
use crate::SecondsFormat::*;
let pst = FixedOffset::east(8 * 60 * 60);
let dt = pst.ymd(2018, 1, 11).and_hms_nano(10, 5, 13, 84_660_000);
assert_eq!(dt.to_rfc3339_opts(Secs, false), "2018-01-11T10:05:13+08:00");
@ -2797,7 +2797,7 @@ mod tests {
#[test]
#[should_panic]
fn test_rfc3339_opts_nonexhaustive() {
use SecondsFormat;
use crate::SecondsFormat;
let dt = Utc.ymd(1999, 10, 9).and_hms(1, 2, 3);
dt.to_rfc3339_opts(SecondsFormat::__NonExhaustive, true);
}

View File

@ -47,22 +47,22 @@ use core::str::FromStr;
use std::error::Error;
#[cfg(any(feature = "alloc", feature = "std", test))]
use naive::{NaiveDate, NaiveTime};
use crate::naive::{NaiveDate, NaiveTime};
#[cfg(any(feature = "alloc", feature = "std", test))]
use offset::{FixedOffset, Offset};
use crate::offset::{FixedOffset, Offset};
#[cfg(any(feature = "alloc", feature = "std", test))]
use {Datelike, Timelike};
use {Month, ParseMonthError, ParseWeekdayError, Weekday};
use crate::{Datelike, Timelike};
use crate::{Month, ParseMonthError, ParseWeekdayError, Weekday};
#[cfg(feature = "unstable-locales")]
pub(crate) mod locales;
pub use self::parse::parse;
pub use self::parsed::Parsed;
pub use self::strftime::StrftimeItems;
pub use parse::parse;
pub use parsed::Parsed;
/// L10n locales.
#[cfg(feature = "unstable-locales")]
pub use pure_rust_locales::Locale;
pub use strftime::StrftimeItems;
#[cfg(not(feature = "unstable-locales"))]
#[derive(Debug)]
@ -465,8 +465,8 @@ fn format_inner<'a>(
)
};
use crate::div::{div_floor, mod_floor};
use core::fmt::Write;
use div::{div_floor, mod_floor};
match *item {
Item::Literal(s) | Item::Space(s) => result.push_str(s),

View File

@ -14,7 +14,7 @@ use super::scan;
use super::{Fixed, InternalFixed, InternalInternal, Item, Numeric, Pad, Parsed};
use super::{ParseError, ParseErrorKind, ParseResult};
use super::{BAD_FORMAT, INVALID, NOT_ENOUGH, OUT_OF_RANGE, TOO_LONG, TOO_SHORT};
use {DateTime, FixedOffset, Weekday};
use crate::{DateTime, FixedOffset, Weekday};
fn set_weekday_with_num_days_from_sunday(p: &mut Parsed, v: i64) -> ParseResult<()> {
p.set_weekday(match v {
@ -809,8 +809,8 @@ fn test_parse() {
fn test_rfc2822() {
use super::NOT_ENOUGH;
use super::*;
use offset::FixedOffset;
use DateTime;
use crate::offset::FixedOffset;
use crate::DateTime;
// Test data - (input, Ok(expected result after parse and format) or Err(error code))
let testdates = [
@ -864,7 +864,7 @@ fn test_rfc2822() {
#[cfg(test)]
#[test]
fn parse_rfc850() {
use {TimeZone, Utc};
use crate::{TimeZone, Utc};
static RFC850_FMT: &'static str = "%A, %d-%b-%y %T GMT";
@ -897,8 +897,8 @@ fn parse_rfc850() {
#[test]
fn test_rfc3339() {
use super::*;
use offset::FixedOffset;
use DateTime;
use crate::offset::FixedOffset;
use crate::DateTime;
// Test data - (input, Ok(expected result after parse and format) or Err(error code))
let testdates = [

View File

@ -4,16 +4,16 @@
//! A collection of parsed date and time items.
//! They can be constructed incrementally while being checked for consistency.
use crate::oldtime::Duration as OldDuration;
use num_traits::ToPrimitive;
use oldtime::Duration as OldDuration;
use super::{ParseResult, IMPOSSIBLE, NOT_ENOUGH, OUT_OF_RANGE};
use div::div_rem;
use naive::{NaiveDate, NaiveDateTime, NaiveTime};
use offset::{FixedOffset, LocalResult, Offset, TimeZone};
use DateTime;
use Weekday;
use {Datelike, Timelike};
use crate::div::div_rem;
use crate::naive::{NaiveDate, NaiveDateTime, NaiveTime};
use crate::offset::{FixedOffset, LocalResult, Offset, TimeZone};
use crate::DateTime;
use crate::Weekday;
use crate::{Datelike, Timelike};
/// Parsed parts of date and time. There are two classes of methods:
///
@ -693,10 +693,10 @@ impl Parsed {
mod tests {
use super::super::{IMPOSSIBLE, NOT_ENOUGH, OUT_OF_RANGE};
use super::Parsed;
use naive::{NaiveDate, NaiveTime, MAX_DATE, MIN_DATE};
use offset::{FixedOffset, TimeZone, Utc};
use Datelike;
use Weekday::*;
use crate::naive::{NaiveDate, NaiveTime, MAX_DATE, MIN_DATE};
use crate::offset::{FixedOffset, TimeZone, Utc};
use crate::Datelike;
use crate::Weekday::*;
#[test]
fn test_parsed_set_fields() {

View File

@ -8,7 +8,7 @@
#![allow(deprecated)]
use super::{ParseResult, INVALID, OUT_OF_RANGE, TOO_SHORT};
use Weekday;
use crate::Weekday;
/// Returns true when two slices are equal case-insensitively (in ASCII).
/// Assumes that the `pattern` is already converted to lower case.
@ -62,7 +62,7 @@ pub fn number(s: &str, min: usize, max: usize) -> ParseResult<(&str, i64)> {
};
}
Ok((&s[::core::cmp::min(max, bytes.len())..], n))
Ok((&s[core::cmp::min(max, bytes.len())..], n))
}
/// Tries to consume at least one digits as a fractional second.

View File

@ -540,7 +540,7 @@ fn test_strftime_items() {
#[cfg(test)]
#[test]
fn test_strftime_docs() {
use {FixedOffset, TimeZone, Timelike};
use crate::{FixedOffset, TimeZone, Timelike};
let dt = FixedOffset::east(34200).ymd(2001, 7, 8).and_hms_nano(0, 34, 59, 1_026_490_708);
@ -618,7 +618,7 @@ fn test_strftime_docs() {
#[cfg(feature = "unstable-locales")]
#[test]
fn test_strftime_docs_localized() {
use {FixedOffset, TimeZone};
use crate::{FixedOffset, TimeZone};
let dt = FixedOffset::east(34200).ymd(2001, 7, 8).and_hms_nano(0, 34, 59, 1_026_490_708);

View File

@ -518,25 +518,25 @@ pub use round::{DurationRound, RoundingError, SubsecRound};
/// A convenience module appropriate for glob imports (`use chrono::prelude::*;`).
pub mod prelude {
#[doc(no_inline)]
pub use Date;
pub use crate::Date;
#[cfg(feature = "clock")]
#[doc(no_inline)]
pub use Local;
pub use crate::Local;
#[cfg(feature = "unstable-locales")]
#[doc(no_inline)]
pub use Locale;
pub use crate::Locale;
#[doc(no_inline)]
pub use SubsecRound;
pub use crate::SubsecRound;
#[doc(no_inline)]
pub use {DateTime, SecondsFormat};
pub use crate::{DateTime, SecondsFormat};
#[doc(no_inline)]
pub use {Datelike, Month, Timelike, Weekday};
pub use crate::{Datelike, Month, Timelike, Weekday};
#[doc(no_inline)]
pub use {FixedOffset, Utc};
pub use crate::{FixedOffset, Utc};
#[doc(no_inline)]
pub use {NaiveDate, NaiveDateTime, NaiveTime};
pub use crate::{NaiveDate, NaiveDateTime, NaiveTime};
#[doc(no_inline)]
pub use {Offset, TimeZone};
pub use crate::{Offset, TimeZone};
}
// useful throughout the codebase

View File

@ -3,20 +3,20 @@
//! ISO 8601 calendar date without timezone.
use crate::oldtime::Duration as OldDuration;
#[cfg(any(feature = "alloc", feature = "std", test))]
use core::borrow::Borrow;
use core::ops::{Add, AddAssign, Sub, SubAssign};
use core::{fmt, str};
use num_traits::ToPrimitive;
use oldtime::Duration as OldDuration;
use div::div_mod_floor;
use crate::div::div_mod_floor;
#[cfg(any(feature = "alloc", feature = "std", test))]
use format::DelayedFormat;
use format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
use format::{Item, Numeric, Pad};
use naive::{IsoWeek, NaiveDateTime, NaiveTime};
use {Datelike, Weekday};
use crate::format::DelayedFormat;
use crate::format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
use crate::format::{Item, Numeric, Pad};
use crate::naive::{IsoWeek, NaiveDateTime, NaiveTime};
use crate::{Datelike, Weekday};
use super::internals::{self, DateImpl, Mdf, Of, YearFlags};
use super::isoweek;
@ -1906,9 +1906,9 @@ mod tests {
use super::NaiveDate;
use super::{MAX_DATE, MAX_DAYS_FROM_YEAR_0, MAX_YEAR};
use super::{MIN_DATE, MIN_DAYS_FROM_YEAR_0, MIN_YEAR};
use oldtime::Duration;
use crate::oldtime::Duration;
use crate::{Datelike, Weekday};
use std::{i32, u32};
use {Datelike, Weekday};
#[test]
fn test_date_from_ymd() {

View File

@ -3,22 +3,22 @@
//! ISO 8601 date and time without timezone.
use crate::oldtime::Duration as OldDuration;
#[cfg(any(feature = "alloc", feature = "std", test))]
use core::borrow::Borrow;
use core::ops::{Add, AddAssign, Sub, SubAssign};
use core::{fmt, hash, str};
use num_traits::ToPrimitive;
use oldtime::Duration as OldDuration;
use div::div_mod_floor;
use crate::div::div_mod_floor;
#[cfg(any(feature = "alloc", feature = "std", test))]
use format::DelayedFormat;
use format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
use format::{Fixed, Item, Numeric, Pad};
use naive::date::{MAX_DATE, MIN_DATE};
use naive::time::{MAX_TIME, MIN_TIME};
use naive::{IsoWeek, NaiveDate, NaiveTime};
use {Datelike, Timelike, Weekday};
use crate::format::DelayedFormat;
use crate::format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
use crate::format::{Fixed, Item, Numeric, Pad};
use crate::naive::date::{MAX_DATE, MIN_DATE};
use crate::naive::time::{MAX_TIME, MIN_TIME};
use crate::naive::{IsoWeek, NaiveDate, NaiveTime};
use crate::{Datelike, Timelike, Weekday};
/// The tight upper bound guarantees that a duration with `|Duration| >= 2^MAX_SECS_BITS`
/// will always overflow the addition with any date and time type.
@ -1401,7 +1401,7 @@ impl Sub<NaiveDateTime> for NaiveDateTime {
}
/// The `Debug` output of the naive date and time `dt` is the same as
/// [`dt.format("%Y-%m-%dT%H:%M:%S%.f")`](::format::strftime).
/// [`dt.format("%Y-%m-%dT%H:%M:%S%.f")`](crate::format::strftime).
///
/// The string printed can be readily parsed via the `parse` method on `str`.
///
@ -1434,7 +1434,7 @@ impl fmt::Debug for NaiveDateTime {
}
/// The `Display` output of the naive date and time `dt` is the same as
/// [`dt.format("%Y-%m-%d %H:%M:%S%.f")`](::format::strftime).
/// [`dt.format("%Y-%m-%d %H:%M:%S%.f")`](crate::format::strftime).
///
/// It should be noted that, for leap seconds not on the minute boundary,
/// it may print a representation not distinguishable from non-leap seconds.
@ -1465,7 +1465,7 @@ impl fmt::Display for NaiveDateTime {
}
/// Parsing a `str` into a `NaiveDateTime` uses the same format,
/// [`%Y-%m-%dT%H:%M:%S%.f`](::format::strftime), as in `Debug`.
/// [`%Y-%m-%dT%H:%M:%S%.f`](crate::format::strftime), as in `Debug`.
///
/// # Example
///
@ -1810,7 +1810,7 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use {ne_timestamp, NaiveDateTime};
use crate::{ne_timestamp, NaiveDateTime};
/// Serialize a UTC datetime into an integer number of nanoseconds since the epoch
///
@ -1962,7 +1962,7 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use {ne_timestamp, NaiveDateTime};
use crate::{ne_timestamp, NaiveDateTime};
/// Serialize a UTC datetime into an integer number of milliseconds since the epoch
///
@ -2111,7 +2111,7 @@ pub mod serde {
use core::fmt;
use serdelib::{de, ser};
use {ne_timestamp, NaiveDateTime};
use crate::{ne_timestamp, NaiveDateTime};
/// Serialize a UTC datetime into an integer number of seconds since the epoch
///
@ -2240,7 +2240,7 @@ pub mod serde {
#[test]
fn test_serde_bincode() {
use self::bincode::{deserialize, serialize, Infinite};
use naive::NaiveDate;
use crate::naive::NaiveDate;
let dt = NaiveDate::from_ymd(2016, 7, 8).and_hms_milli(9, 10, 48, 90);
let encoded = serialize(&dt, Infinite).unwrap();
@ -2252,8 +2252,8 @@ pub mod serde {
fn test_serde_bincode_optional() {
use self::bincode::{deserialize, serialize, Infinite};
use self::serde_derive::{Deserialize, Serialize};
use prelude::*;
use serde::ts_nanoseconds_option;
use crate::prelude::*;
use crate::serde::ts_nanoseconds_option;
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
struct Test {
@ -2273,10 +2273,10 @@ pub mod serde {
#[cfg(test)]
mod tests {
use super::NaiveDateTime;
use naive::{NaiveDate, MAX_DATE, MIN_DATE};
use oldtime::Duration;
use crate::naive::{NaiveDate, MAX_DATE, MIN_DATE};
use crate::oldtime::Duration;
use crate::Datelike;
use std::i64;
use Datelike;
#[test]
fn test_datetime_from_timestamp() {

View File

@ -16,10 +16,10 @@
#![allow(dead_code)] // some internal methods have been left for consistency
#![cfg_attr(feature = "__internal_bench", allow(missing_docs))]
use crate::div::{div_rem, mod_floor};
use crate::Weekday;
use core::{fmt, i32};
use div::{div_rem, mod_floor};
use num_traits::FromPrimitive;
use Weekday;
/// The internal date representation. This also includes the packed `Mdf` value.
pub type DateImpl = i32;
@ -490,8 +490,8 @@ mod tests {
use self::num_iter::range_inclusive;
use super::{Mdf, Of};
use super::{YearFlags, A, AG, B, BA, C, CB, D, DC, E, ED, F, FE, G, GF};
use crate::Weekday;
use std::u32;
use Weekday;
const NONLEAP_FLAGS: [YearFlags; 7] = [A, B, C, D, E, F, G];
const LEAP_FLAGS: [YearFlags; 7] = [AG, BA, CB, DC, ED, FE, GF];

View File

@ -142,8 +142,8 @@ impl fmt::Debug for IsoWeek {
#[cfg(test)]
mod tests {
use naive::{internals, MAX_DATE, MIN_DATE};
use Datelike;
use crate::naive::{internals, MAX_DATE, MIN_DATE};
use crate::Datelike;
#[test]
fn test_iso_week_extremes() {

View File

@ -3,18 +3,18 @@
//! ISO 8601 time without timezone.
use crate::oldtime::Duration as OldDuration;
#[cfg(any(feature = "alloc", feature = "std", test))]
use core::borrow::Borrow;
use core::ops::{Add, AddAssign, Sub, SubAssign};
use core::{fmt, hash, str};
use oldtime::Duration as OldDuration;
use div::div_mod_floor;
use crate::div::div_mod_floor;
#[cfg(any(feature = "alloc", feature = "std", test))]
use format::DelayedFormat;
use format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
use format::{Fixed, Item, Numeric, Pad};
use Timelike;
use crate::format::DelayedFormat;
use crate::format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
use crate::format::{Fixed, Item, Numeric, Pad};
use crate::Timelike;
pub const MIN_TIME: NaiveTime = NaiveTime { secs: 0, frac: 0 };
pub const MAX_TIME: NaiveTime = NaiveTime { secs: 23 * 3600 + 59 * 60 + 59, frac: 999_999_999 };
@ -1541,9 +1541,9 @@ mod serde {
#[cfg(test)]
mod tests {
use super::NaiveTime;
use oldtime::Duration;
use crate::oldtime::Duration;
use crate::Timelike;
use std::u32;
use Timelike;
#[test]
fn test_time_from_hms_milli() {

View File

@ -3,15 +3,15 @@
//! The time zone which has a fixed offset from UTC.
use crate::oldtime::Duration as OldDuration;
use core::fmt;
use core::ops::{Add, Sub};
use oldtime::Duration as OldDuration;
use super::{LocalResult, Offset, TimeZone};
use div::div_mod_floor;
use naive::{NaiveDate, NaiveDateTime, NaiveTime};
use DateTime;
use Timelike;
use crate::div::div_mod_floor;
use crate::naive::{NaiveDate, NaiveDateTime, NaiveTime};
use crate::DateTime;
use crate::Timelike;
/// The time zone with fixed offset, from UTC-23:59:59 to UTC+23:59:59.
///
@ -218,7 +218,7 @@ impl<Tz: TimeZone> Sub<FixedOffset> for DateTime<Tz> {
#[cfg(test)]
mod tests {
use super::FixedOffset;
use offset::TimeZone;
use crate::offset::TimeZone;
#[test]
fn test_date_extreme_offset() {

View File

@ -4,16 +4,16 @@
//! The local (system) time zone.
#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")))]
use sys::{self, Timespec};
use crate::sys::{self, Timespec};
use super::fixed::FixedOffset;
use super::{LocalResult, TimeZone};
#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")))]
use naive::NaiveTime;
use naive::{NaiveDate, NaiveDateTime};
use {Date, DateTime};
use crate::naive::NaiveTime;
use crate::naive::{NaiveDate, NaiveDateTime};
use crate::{Date, DateTime};
#[cfg(not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind")))]
use {Datelike, Timelike};
use crate::{Datelike, Timelike};
/// Converts a `time::Tm` struct into the timezone-aware `DateTime`.
/// This assumes that `time` is working correctly, i.e. any error is fatal.
@ -196,8 +196,8 @@ impl TimeZone for Local {
#[cfg(test)]
mod tests {
use super::Local;
use offset::TimeZone;
use Datelike;
use crate::offset::TimeZone;
use crate::Datelike;
#[test]
fn test_local_date_sanity_check() {

View File

@ -20,10 +20,10 @@
use core::fmt;
use format::{parse, ParseResult, Parsed, StrftimeItems};
use naive::{NaiveDate, NaiveDateTime, NaiveTime};
use Weekday;
use {Date, DateTime};
use crate::format::{parse, ParseResult, Parsed, StrftimeItems};
use crate::naive::{NaiveDate, NaiveDateTime, NaiveTime};
use crate::Weekday;
use crate::{Date, DateTime};
/// The conversion result from the local time to the timezone-aware datetime types.
#[derive(Clone, PartialEq, Debug, Copy, Eq, Hash)]
@ -406,7 +406,7 @@ pub trait TimeZone: Sized + Clone {
/// Parses a string with the specified format string and returns a
/// `DateTime` with the current offset.
///
/// See the [`::format::strftime`] module on the
/// See the [`crate::format::strftime`] module on the
/// supported escape sequences.
///
/// If the to-be-parsed string includes an offset, it *must* match the

View File

@ -6,14 +6,14 @@
use core::fmt;
use super::{FixedOffset, LocalResult, Offset, TimeZone};
use naive::{NaiveDate, NaiveDateTime};
use crate::naive::{NaiveDate, NaiveDateTime};
#[cfg(feature = "clock")]
use crate::{Date, DateTime};
#[cfg(all(
feature = "clock",
not(all(target_arch = "wasm32", not(target_os = "wasi"), feature = "wasmbind"))
))]
use std::time::{SystemTime, UNIX_EPOCH};
#[cfg(feature = "clock")]
use {Date, DateTime};
/// The UTC time zone. This is the most efficient time zone when you don't need the local time.
/// It is also used as an offset (which is also a dummy type).

View File

@ -1,17 +1,15 @@
// This is a part of Chrono.
// See README.md and LICENSE.txt for details.
use crate::datetime::DateTime;
use crate::naive::NaiveDateTime;
use crate::oldtime::Duration;
use crate::TimeZone;
use crate::Timelike;
use core::cmp::Ordering;
use core::fmt;
use core::marker::Sized;
use core::ops::{Add, Sub};
use datetime::DateTime;
use naive::NaiveDateTime;
use oldtime::Duration;
#[cfg(any(feature = "std", test))]
use std;
use TimeZone;
use Timelike;
/// Extension trait for subsecond rounding or truncation to a maximum number
/// of digits. Rounding can be used to decrease the error variance when
@ -303,8 +301,8 @@ impl std::error::Error for RoundingError {
#[cfg(test)]
mod tests {
use super::{Duration, DurationRound, SubsecRound};
use offset::{FixedOffset, TimeZone, Utc};
use Timelike;
use crate::offset::{FixedOffset, TimeZone, Utc};
use crate::Timelike;
#[test]
fn test_round_subsecs() {