mirror of
https://github.com/chronotope/chrono.git
synced 2025-09-28 21:42:01 +00:00
parent
a905c556d8
commit
aaee912228
@ -10,6 +10,10 @@ Versions with only mechanical changes will be omitted from the following list.
|
||||
|
||||
## 0.4.14 (unreleased)
|
||||
|
||||
## Improvements
|
||||
|
||||
* Added MIN and MAX values for `NaiveTime`, `NaiveDateTime` and `DateTime<Utc>`.
|
||||
|
||||
|
||||
## 0.4.13
|
||||
|
||||
|
@ -21,7 +21,7 @@ use core::borrow::Borrow;
|
||||
use format::DelayedFormat;
|
||||
use format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
|
||||
use format::{Fixed, Item};
|
||||
use naive::{IsoWeek, NaiveDateTime, NaiveTime};
|
||||
use naive::{self, IsoWeek, NaiveDateTime, NaiveTime};
|
||||
#[cfg(feature = "clock")]
|
||||
use offset::Local;
|
||||
use offset::{FixedOffset, Offset, TimeZone, Utc};
|
||||
@ -70,6 +70,11 @@ pub struct DateTime<Tz: TimeZone> {
|
||||
offset: Tz::Offset,
|
||||
}
|
||||
|
||||
/// The minimum possilbe `DateTime<Utc>`.
|
||||
pub const MIN_DATETIME: DateTime<Utc> = DateTime { datetime: naive::MIN_DATETIME, offset: Utc };
|
||||
/// The maximum possible `DateTime<Utc>`.
|
||||
pub const MAX_DATETIME: DateTime<Utc> = DateTime { datetime: naive::MAX_DATETIME, offset: Utc };
|
||||
|
||||
impl<Tz: TimeZone> DateTime<Tz> {
|
||||
/// Makes a new `DateTime` with given *UTC* datetime and offset.
|
||||
/// The local datetime should be constructed via the `TimeZone` trait.
|
||||
|
@ -450,7 +450,7 @@ pub use oldtime::Duration;
|
||||
pub use date::{Date, MAX_DATE, MIN_DATE};
|
||||
#[cfg(feature = "rustc-serialize")]
|
||||
pub use datetime::rustc_serialize::TsSeconds;
|
||||
pub use datetime::{DateTime, SecondsFormat};
|
||||
pub use datetime::{DateTime, SecondsFormat, MAX_DATETIME, MIN_DATETIME};
|
||||
pub use format::{ParseError, ParseResult};
|
||||
#[doc(no_inline)]
|
||||
pub use naive::{IsoWeek, NaiveDate, NaiveDateTime, NaiveTime};
|
||||
@ -511,7 +511,7 @@ pub mod naive {
|
||||
#[cfg(feature = "rustc-serialize")]
|
||||
#[allow(deprecated)]
|
||||
pub use self::datetime::rustc_serialize::TsSeconds;
|
||||
pub use self::datetime::NaiveDateTime;
|
||||
pub use self::datetime::{NaiveDateTime, MAX_DATETIME, MIN_DATETIME};
|
||||
pub use self::isoweek::IsoWeek;
|
||||
pub use self::time::NaiveTime;
|
||||
|
||||
|
@ -15,6 +15,8 @@ use div::div_mod_floor;
|
||||
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};
|
||||
|
||||
@ -26,6 +28,11 @@ use {Datelike, Timelike, Weekday};
|
||||
/// touching that call when we are already sure that it WILL overflow...
|
||||
const MAX_SECS_BITS: usize = 44;
|
||||
|
||||
/// The minimum possible `NaiveDateTime`.
|
||||
pub const MIN_DATETIME: NaiveDateTime = NaiveDateTime { date: MIN_DATE, time: MIN_TIME };
|
||||
/// The maximum possible `NaiveDateTime`.
|
||||
pub const MAX_DATETIME: NaiveDateTime = NaiveDateTime { date: MAX_DATE, time: MAX_TIME };
|
||||
|
||||
/// ISO 8601 combined date and time without timezone.
|
||||
///
|
||||
/// # Example
|
||||
|
@ -16,6 +16,9 @@ use format::{parse, ParseError, ParseResult, Parsed, StrftimeItems};
|
||||
use format::{Fixed, Item, Numeric, Pad};
|
||||
use 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 };
|
||||
|
||||
/// ISO 8601 time without timezone.
|
||||
/// Allows for the nanosecond precision and optional leap second representation.
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user