pub struct UtcDate(_);
Expand description
A Puff Date for UTC.
Implementations
Methods from Deref<Target = Date<Utc>>
sourcepub fn and_time(&self, time: NaiveTime) -> Option<DateTime<Tz>>
pub fn and_time(&self, time: NaiveTime) -> Option<DateTime<Tz>>
Makes a new DateTime
from the current date and given NaiveTime
.
The offset in the current date is preserved.
Panics on invalid datetime.
sourcepub fn and_hms(&self, hour: u32, min: u32, sec: u32) -> DateTime<Tz>
pub fn and_hms(&self, hour: u32, min: u32, sec: u32) -> DateTime<Tz>
Makes a new DateTime
from the current date, hour, minute and second.
The offset in the current date is preserved.
Panics on invalid hour, minute and/or second.
sourcepub fn and_hms_opt(&self, hour: u32, min: u32, sec: u32) -> Option<DateTime<Tz>>
pub fn and_hms_opt(&self, hour: u32, min: u32, sec: u32) -> Option<DateTime<Tz>>
Makes a new DateTime
from the current date, hour, minute and second.
The offset in the current date is preserved.
Returns None
on invalid hour, minute and/or second.
sourcepub fn and_hms_milli(
&self,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> DateTime<Tz>
pub fn and_hms_milli(
&self,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> DateTime<Tz>
Makes a new DateTime
from the current date, hour, minute, second and millisecond.
The millisecond part can exceed 1,000 in order to represent the leap second.
The offset in the current date is preserved.
Panics on invalid hour, minute, second and/or millisecond.
sourcepub fn and_hms_milli_opt(
&self,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> Option<DateTime<Tz>>
pub fn and_hms_milli_opt(
&self,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> Option<DateTime<Tz>>
Makes a new DateTime
from the current date, hour, minute, second and millisecond.
The millisecond part can exceed 1,000 in order to represent the leap second.
The offset in the current date is preserved.
Returns None
on invalid hour, minute, second and/or millisecond.
sourcepub fn and_hms_micro(
&self,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> DateTime<Tz>
pub fn and_hms_micro(
&self,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> DateTime<Tz>
Makes a new DateTime
from the current date, hour, minute, second and microsecond.
The microsecond part can exceed 1,000,000 in order to represent the leap second.
The offset in the current date is preserved.
Panics on invalid hour, minute, second and/or microsecond.
sourcepub fn and_hms_micro_opt(
&self,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> Option<DateTime<Tz>>
pub fn and_hms_micro_opt(
&self,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> Option<DateTime<Tz>>
Makes a new DateTime
from the current date, hour, minute, second and microsecond.
The microsecond part can exceed 1,000,000 in order to represent the leap second.
The offset in the current date is preserved.
Returns None
on invalid hour, minute, second and/or microsecond.
sourcepub fn and_hms_nano(&self, hour: u32, min: u32, sec: u32, nano: u32) -> DateTime<Tz>
pub fn and_hms_nano(&self, hour: u32, min: u32, sec: u32, nano: u32) -> DateTime<Tz>
Makes a new DateTime
from the current date, hour, minute, second and nanosecond.
The nanosecond part can exceed 1,000,000,000 in order to represent the leap second.
The offset in the current date is preserved.
Panics on invalid hour, minute, second and/or nanosecond.
sourcepub fn and_hms_nano_opt(
&self,
hour: u32,
min: u32,
sec: u32,
nano: u32
) -> Option<DateTime<Tz>>
pub fn and_hms_nano_opt(
&self,
hour: u32,
min: u32,
sec: u32,
nano: u32
) -> Option<DateTime<Tz>>
Makes a new DateTime
from the current date, hour, minute, second and nanosecond.
The nanosecond part can exceed 1,000,000,000 in order to represent the leap second.
The offset in the current date is preserved.
Returns None
on invalid hour, minute, second and/or nanosecond.
sourcepub fn succ(&self) -> Date<Tz>
pub fn succ(&self) -> Date<Tz>
Makes a new Date
for the next date.
Panics when self
is the last representable date.
sourcepub fn succ_opt(&self) -> Option<Date<Tz>>
pub fn succ_opt(&self) -> Option<Date<Tz>>
Makes a new Date
for the next date.
Returns None
when self
is the last representable date.
sourcepub fn pred(&self) -> Date<Tz>
pub fn pred(&self) -> Date<Tz>
Makes a new Date
for the prior date.
Panics when self
is the first representable date.
sourcepub fn pred_opt(&self) -> Option<Date<Tz>>
pub fn pred_opt(&self) -> Option<Date<Tz>>
Makes a new Date
for the prior date.
Returns None
when self
is the first representable date.
sourcepub fn with_timezone<Tz2>(&self, tz: &Tz2) -> Date<Tz2>where
Tz2: TimeZone,
pub fn with_timezone<Tz2>(&self, tz: &Tz2) -> Date<Tz2>where
Tz2: TimeZone,
Changes the associated time zone.
This does not change the actual Date
(but will change the string representation).
sourcepub fn naive_local(&self) -> NaiveDate
pub fn naive_local(&self) -> NaiveDate
Returns a view to the naive local date.
This is technically the same as naive_utc
because the offset is restricted to never exceed one day,
but provided for the consistency.
sourcepub fn years_since(&self, base: Date<Tz>) -> Option<u32>
pub fn years_since(&self, base: Date<Tz>) -> Option<u32>
Returns the number of whole years from the given base
until self
.
pub const MIN_UTC: Date<Utc> = Date{ date: NaiveDate::MIN, offset: Utc,}
pub const MAX_UTC: Date<Utc> = Date{ date: NaiveDate::MAX, offset: Utc,}
sourcepub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>where
I: Iterator<Item = B> + Clone,
B: Borrow<Item<'a>>,
pub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I>where
I: Iterator<Item = B> + Clone,
B: Borrow<Item<'a>>,
Formats the date with the specified formatting items.
sourcepub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>>
pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>>
Formats the date with the specified format string.
See the crate::format::strftime
module
on the supported escape sequences.
Example
use chrono::prelude::*;
let date_time: Date<Utc> = Utc.ymd(2017, 04, 02);
let formatted = format!("{}", date_time.format("%d/%m/%Y"));
assert_eq!(formatted, "02/04/2017");