[−][src]Struct liquid::model::scalar::Date
Liquid's native date only type.
Implementations
impl Date
[src]
pub fn from_ymd(year: i32, month: u32, day: u32) -> Date
[src]
Makes a new NaiveDate from the calendar date (year, month and day).
Panics on the out-of-range date, invalid month and/or day.
pub fn from_str(other: &str) -> Option<Date>
[src]
Convert a str
to Self
Methods from Deref<Target = NaiveDate>
pub fn and_time(&self, time: NaiveTime) -> NaiveDateTime
[src]
Makes a new NaiveDateTime
from the current date and given NaiveTime
.
Example
use chrono::{NaiveDate, NaiveTime, NaiveDateTime}; let d = NaiveDate::from_ymd(2015, 6, 3); let t = NaiveTime::from_hms_milli(12, 34, 56, 789); let dt: NaiveDateTime = d.and_time(t); assert_eq!(dt.date(), d); assert_eq!(dt.time(), t);
pub fn and_hms(&self, hour: u32, min: u32, sec: u32) -> NaiveDateTime
[src]
Makes a new NaiveDateTime
from the current date, hour, minute and second.
No leap second is allowed here;
use NaiveDate::and_hms_*
methods with a subsecond parameter instead.
Panics on invalid hour, minute and/or second.
Example
use chrono::{NaiveDate, NaiveDateTime, Datelike, Timelike, Weekday}; let d = NaiveDate::from_ymd(2015, 6, 3); let dt: NaiveDateTime = d.and_hms(12, 34, 56); assert_eq!(dt.year(), 2015); assert_eq!(dt.weekday(), Weekday::Wed); assert_eq!(dt.second(), 56);
pub fn and_hms_opt(
&self,
hour: u32,
min: u32,
sec: u32
) -> Option<NaiveDateTime>
[src]
&self,
hour: u32,
min: u32,
sec: u32
) -> Option<NaiveDateTime>
Makes a new NaiveDateTime
from the current date, hour, minute and second.
No leap second is allowed here;
use NaiveDate::and_hms_*_opt
methods with a subsecond parameter instead.
Returns None
on invalid hour, minute and/or second.
Example
use chrono::NaiveDate; let d = NaiveDate::from_ymd(2015, 6, 3); assert!(d.and_hms_opt(12, 34, 56).is_some()); assert!(d.and_hms_opt(12, 34, 60).is_none()); // use `and_hms_milli_opt` instead assert!(d.and_hms_opt(12, 60, 56).is_none()); assert!(d.and_hms_opt(24, 34, 56).is_none());
pub fn and_hms_milli(
&self,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> NaiveDateTime
[src]
&self,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> NaiveDateTime
Makes a new NaiveDateTime
from the current date, hour, minute, second and millisecond.
The millisecond part can exceed 1,000 in order to represent the leap second.
Panics on invalid hour, minute, second and/or millisecond.
Example
use chrono::{NaiveDate, NaiveDateTime, Datelike, Timelike, Weekday}; let d = NaiveDate::from_ymd(2015, 6, 3); let dt: NaiveDateTime = d.and_hms_milli(12, 34, 56, 789); assert_eq!(dt.year(), 2015); assert_eq!(dt.weekday(), Weekday::Wed); assert_eq!(dt.second(), 56); assert_eq!(dt.nanosecond(), 789_000_000);
pub fn and_hms_milli_opt(
&self,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> Option<NaiveDateTime>
[src]
&self,
hour: u32,
min: u32,
sec: u32,
milli: u32
) -> Option<NaiveDateTime>
Makes a new NaiveDateTime
from the current date, hour, minute, second and millisecond.
The millisecond part can exceed 1,000 in order to represent the leap second.
Returns None
on invalid hour, minute, second and/or millisecond.
Example
use chrono::NaiveDate; let d = NaiveDate::from_ymd(2015, 6, 3); assert!(d.and_hms_milli_opt(12, 34, 56, 789).is_some()); assert!(d.and_hms_milli_opt(12, 34, 59, 1_789).is_some()); // leap second assert!(d.and_hms_milli_opt(12, 34, 59, 2_789).is_none()); assert!(d.and_hms_milli_opt(12, 34, 60, 789).is_none()); assert!(d.and_hms_milli_opt(12, 60, 56, 789).is_none()); assert!(d.and_hms_milli_opt(24, 34, 56, 789).is_none());
pub fn and_hms_micro(
&self,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> NaiveDateTime
[src]
&self,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> NaiveDateTime
Makes a new NaiveDateTime
from the current date, hour, minute, second and microsecond.
The microsecond part can exceed 1,000,000 in order to represent the leap second.
Panics on invalid hour, minute, second and/or microsecond.
Example
use chrono::{NaiveDate, NaiveDateTime, Datelike, Timelike, Weekday}; let d = NaiveDate::from_ymd(2015, 6, 3); let dt: NaiveDateTime = d.and_hms_micro(12, 34, 56, 789_012); assert_eq!(dt.year(), 2015); assert_eq!(dt.weekday(), Weekday::Wed); assert_eq!(dt.second(), 56); assert_eq!(dt.nanosecond(), 789_012_000);
pub fn and_hms_micro_opt(
&self,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> Option<NaiveDateTime>
[src]
&self,
hour: u32,
min: u32,
sec: u32,
micro: u32
) -> Option<NaiveDateTime>
Makes a new NaiveDateTime
from the current date, hour, minute, second and microsecond.
The microsecond part can exceed 1,000,000 in order to represent the leap second.
Returns None
on invalid hour, minute, second and/or microsecond.
Example
use chrono::NaiveDate; let d = NaiveDate::from_ymd(2015, 6, 3); assert!(d.and_hms_micro_opt(12, 34, 56, 789_012).is_some()); assert!(d.and_hms_micro_opt(12, 34, 59, 1_789_012).is_some()); // leap second assert!(d.and_hms_micro_opt(12, 34, 59, 2_789_012).is_none()); assert!(d.and_hms_micro_opt(12, 34, 60, 789_012).is_none()); assert!(d.and_hms_micro_opt(12, 60, 56, 789_012).is_none()); assert!(d.and_hms_micro_opt(24, 34, 56, 789_012).is_none());
pub fn and_hms_nano(
&self,
hour: u32,
min: u32,
sec: u32,
nano: u32
) -> NaiveDateTime
[src]
&self,
hour: u32,
min: u32,
sec: u32,
nano: u32
) -> NaiveDateTime
Makes a new NaiveDateTime
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.
Panics on invalid hour, minute, second and/or nanosecond.
Example
use chrono::{NaiveDate, NaiveDateTime, Datelike, Timelike, Weekday}; let d = NaiveDate::from_ymd(2015, 6, 3); let dt: NaiveDateTime = d.and_hms_nano(12, 34, 56, 789_012_345); assert_eq!(dt.year(), 2015); assert_eq!(dt.weekday(), Weekday::Wed); assert_eq!(dt.second(), 56); assert_eq!(dt.nanosecond(), 789_012_345);
pub fn and_hms_nano_opt(
&self,
hour: u32,
min: u32,
sec: u32,
nano: u32
) -> Option<NaiveDateTime>
[src]
&self,
hour: u32,
min: u32,
sec: u32,
nano: u32
) -> Option<NaiveDateTime>
Makes a new NaiveDateTime
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.
Returns None
on invalid hour, minute, second and/or nanosecond.
Example
use chrono::NaiveDate; let d = NaiveDate::from_ymd(2015, 6, 3); assert!(d.and_hms_nano_opt(12, 34, 56, 789_012_345).is_some()); assert!(d.and_hms_nano_opt(12, 34, 59, 1_789_012_345).is_some()); // leap second assert!(d.and_hms_nano_opt(12, 34, 59, 2_789_012_345).is_none()); assert!(d.and_hms_nano_opt(12, 34, 60, 789_012_345).is_none()); assert!(d.and_hms_nano_opt(12, 60, 56, 789_012_345).is_none()); assert!(d.and_hms_nano_opt(24, 34, 56, 789_012_345).is_none());
pub fn succ(&self) -> NaiveDate
[src]
Makes a new NaiveDate
for the next calendar date.
Panics when self
is the last representable date.
Example
use chrono::NaiveDate; assert_eq!(NaiveDate::from_ymd(2015, 6, 3).succ(), NaiveDate::from_ymd(2015, 6, 4)); assert_eq!(NaiveDate::from_ymd(2015, 6, 30).succ(), NaiveDate::from_ymd(2015, 7, 1)); assert_eq!(NaiveDate::from_ymd(2015, 12, 31).succ(), NaiveDate::from_ymd(2016, 1, 1));
pub fn succ_opt(&self) -> Option<NaiveDate>
[src]
Makes a new NaiveDate
for the next calendar date.
Returns None
when self
is the last representable date.
Example
use chrono::NaiveDate; use chrono::naive::MAX_DATE; assert_eq!(NaiveDate::from_ymd(2015, 6, 3).succ_opt(), Some(NaiveDate::from_ymd(2015, 6, 4))); assert_eq!(MAX_DATE.succ_opt(), None);
pub fn pred(&self) -> NaiveDate
[src]
Makes a new NaiveDate
for the previous calendar date.
Panics when self
is the first representable date.
Example
use chrono::NaiveDate; assert_eq!(NaiveDate::from_ymd(2015, 6, 3).pred(), NaiveDate::from_ymd(2015, 6, 2)); assert_eq!(NaiveDate::from_ymd(2015, 6, 1).pred(), NaiveDate::from_ymd(2015, 5, 31)); assert_eq!(NaiveDate::from_ymd(2015, 1, 1).pred(), NaiveDate::from_ymd(2014, 12, 31));
pub fn pred_opt(&self) -> Option<NaiveDate>
[src]
Makes a new NaiveDate
for the previous calendar date.
Returns None
when self
is the first representable date.
Example
use chrono::NaiveDate; use chrono::naive::MIN_DATE; assert_eq!(NaiveDate::from_ymd(2015, 6, 3).pred_opt(), Some(NaiveDate::from_ymd(2015, 6, 2))); assert_eq!(MIN_DATE.pred_opt(), None);
pub fn format_with_items<'a, I, B>(&self, items: I) -> DelayedFormat<I> where
B: Borrow<Item<'a>>,
I: Iterator<Item = B> + Clone,
[src]
B: Borrow<Item<'a>>,
I: Iterator<Item = B> + Clone,
Formats the date with the specified formatting items.
Otherwise it is the same as the ordinary format
method.
The Iterator
of items should be Clone
able,
since the resulting DelayedFormat
value may be formatted multiple times.
Example
use chrono::NaiveDate; use chrono::format::strftime::StrftimeItems; let fmt = StrftimeItems::new("%Y-%m-%d"); let d = NaiveDate::from_ymd(2015, 9, 5); assert_eq!(d.format_with_items(fmt.clone()).to_string(), "2015-09-05"); assert_eq!(d.format("%Y-%m-%d").to_string(), "2015-09-05");
The resulting DelayedFormat
can be formatted directly via the Display
trait.
assert_eq!(format!("{}", d.format_with_items(fmt)), "2015-09-05");
pub fn format(&self, fmt: &'a str) -> DelayedFormat<StrftimeItems<'a>>
[src]
Formats the date with the specified format string.
See the format::strftime
module
on the supported escape sequences.
This returns a DelayedFormat
,
which gets converted to a string only when actual formatting happens.
You may use the to_string
method to get a String
,
or just feed it into print!
and other formatting macros.
(In this way it avoids the redundant memory allocation.)
A wrong format string does not issue an error immediately.
Rather, converting or formatting the DelayedFormat
fails.
You are recommended to immediately use DelayedFormat
for this reason.
Example
use chrono::NaiveDate; let d = NaiveDate::from_ymd(2015, 9, 5); assert_eq!(d.format("%Y-%m-%d").to_string(), "2015-09-05"); assert_eq!(d.format("%A, %-d %B, %C%y").to_string(), "Saturday, 5 September, 2015");
The resulting DelayedFormat
can be formatted directly via the Display
trait.
assert_eq!(format!("{}", d.format("%Y-%m-%d")), "2015-09-05"); assert_eq!(format!("{}", d.format("%A, %-d %B, %C%y")), "Saturday, 5 September, 2015");
Trait Implementations
impl Clone for Date
[src]
impl Copy for Date
[src]
impl Datelike for Date
[src]
fn year(&self) -> i32
[src]
fn month(&self) -> u32
[src]
fn month0(&self) -> u32
[src]
fn day(&self) -> u32
[src]
fn day0(&self) -> u32
[src]
fn ordinal(&self) -> u32
[src]
fn ordinal0(&self) -> u32
[src]
fn weekday(&self) -> Weekday
[src]
fn iso_week(&self) -> IsoWeek
[src]
fn with_year(&self, year: i32) -> Option<Date>
[src]
fn with_month(&self, month: u32) -> Option<Date>
[src]
fn with_month0(&self, month0: u32) -> Option<Date>
[src]
fn with_day(&self, day: u32) -> Option<Date>
[src]
fn with_day0(&self, day0: u32) -> Option<Date>
[src]
fn with_ordinal(&self, ordinal: u32) -> Option<Date>
[src]
fn with_ordinal0(&self, ordinal0: u32) -> Option<Date>
[src]
fn year_ce(&self) -> (bool, u32)
[src]
fn num_days_from_ce(&self) -> i32
[src]
impl Debug for Date
[src]
impl Deref for Date
[src]
type Target = NaiveDate
The resulting type after dereferencing.
fn deref(&self) -> &<Date as Deref>::Target
[src]
impl DerefMut for Date
[src]
impl<'de> Deserialize<'de> for Date
[src]
fn deserialize<__D>(
__deserializer: __D
) -> Result<Date, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
[src]
__deserializer: __D
) -> Result<Date, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl Display for Date
[src]
impl Eq for Date
[src]
impl<'s> From<Date> for ScalarCow<'s>
[src]
impl Hash for Date
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Date
[src]
fn cmp(&self, other: &Date) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<'s> PartialEq<Date> for ScalarCow<'s>
[src]
impl<'v> PartialEq<Date> for ValueViewCmp<'v>
[src]
impl<'v> PartialEq<Date> for ValueCow<'v>
[src]
impl PartialEq<Date> for Date
[src]
impl PartialEq<Date> for Value
[src]
impl PartialOrd<Date> for Date
[src]
fn partial_cmp(&self, other: &Date) -> Option<Ordering>
[src]
fn lt(&self, other: &Date) -> bool
[src]
fn le(&self, other: &Date) -> bool
[src]
fn gt(&self, other: &Date) -> bool
[src]
fn ge(&self, other: &Date) -> bool
[src]
impl<'s> PartialOrd<Date> for ScalarCow<'s>
[src]
fn partial_cmp(&self, other: &Date) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for Date
[src]
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
[src]
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
impl StructuralEq for Date
[src]
impl StructuralPartialEq for Date
[src]
impl ValueView for Date
[src]
fn as_debug(&self) -> &dyn Debug
[src]
fn render(&self) -> DisplayCow
[src]
fn source(&self) -> DisplayCow
[src]
fn type_name(&self) -> &'static str
[src]
fn query_state(&self, state: State) -> bool
[src]
fn to_kstr(&self) -> KStringCow
[src]
fn to_value(&self) -> Value
[src]
fn as_scalar(&self) -> Option<ScalarCow>
[src]
fn is_scalar(&self) -> bool
[src]
fn as_array(&self) -> Option<&dyn ArrayView>
[src]
fn is_array(&self) -> bool
[src]
fn as_object(&self) -> Option<&dyn ObjectView>
[src]
fn is_object(&self) -> bool
[src]
fn as_state(&self) -> Option<State>
[src]
fn is_state(&self) -> bool
[src]
fn is_nil(&self) -> bool
[src]
Auto Trait Implementations
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CloneAny for T where
T: Clone + Any,
T: Clone + Any,
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> RuleType for T where
T: Eq + Ord + Copy + Debug + Hash,
[src]
T: Eq + Ord + Copy + Debug + Hash,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,