Struct liquid_core::model::DateTime

source ·
#[repr(transparent)]
pub struct DateTime { /* private fields */ }
Expand description

Liquid’s native date + time type.

Implementations§

source§

impl DateTime

source

pub fn now() -> Self

Create a DateTime from the current moment.

source

pub fn from_ymd(year: i32, month: u8, day: u8) -> Self

Makes a new NaiveDate from the calendar date (year, month and day).

Panics on the out-of-range date, invalid month and/or day.

source

pub fn from_str(other: &str) -> Option<Self>

Convert a str to Self

source

pub fn with_date(self, other: Date) -> Self

Replace date with other.

source

pub fn with_offset(self, offset: UtcOffset) -> Self

Changes the associated time zone. This does not change the actual DateTime (but will change the string representation).

source

pub fn date(self) -> Date

Retrieves a date component.

source

pub fn format(&self, fmt: &str) -> Result<String, DateFormatError>

Formats the combined date and time with the specified format string.

See the chrono::format::strftime module on the supported escape sequences.

source

pub fn to_rfc2822(&self) -> String

Returns an RFC 2822 date and time string such as Tue, 1 Jul 2003 10:52:37 +0200.

source§

impl DateTime

source

pub fn year(&self) -> i32

Get the year of the date.

source

pub fn month(&self) -> u8

Get the month.

source

pub fn day(&self) -> u8

Get the day of the month.

source

pub fn ordinal(&self) -> u16

Get the day of the year.

The returned value will always be in the range 1..=366 (1..=365 for common years).

source

pub fn iso_week(&self) -> u8

Get the ISO week number.

The returned value will always be in the range 1..=53.

Methods from Deref<Target = OffsetDateTime>§

source

pub const UNIX_EPOCH: OffsetDateTime = Self(Inner::UNIX_EPOCH)

Trait Implementations§

source§

impl Clone for DateTime

source§

fn clone(&self) -> DateTime

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for DateTime

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for DateTime

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Deref for DateTime

§

type Target = OffsetDateTime

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for DateTime

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'de> Deserialize<'de> for DateTime

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for DateTime

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'s> From<DateTime> for ScalarCow<'s>

source§

fn from(s: DateTime) -> Self

Converts to this type from the input type.
source§

impl Hash for DateTime

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for DateTime

source§

fn cmp(&self, other: &DateTime) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<DateTime> for DateTime

source§

fn eq(&self, other: &DateTime) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'s> PartialEq<DateTime> for ScalarCow<'s>

source§

fn eq(&self, other: &DateTime) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<DateTime> for Value

source§

fn eq(&self, other: &DateTime) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<DateTime> for ValueCow<'v>

source§

fn eq(&self, other: &DateTime) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<DateTime> for ValueViewCmp<'v>

source§

fn eq(&self, other: &DateTime) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<DateTime> for DateTime

source§

fn partial_cmp(&self, other: &DateTime) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'s> PartialOrd<DateTime> for ScalarCow<'s>

source§

fn partial_cmp(&self, other: &DateTime) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for DateTime

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl ValueView for DateTime

source§

fn as_debug(&self) -> &dyn Debug

Get a Debug representation
source§

fn render(&self) -> DisplayCow<'_>

A Display for a BoxedValue rendered for the user.
source§

fn source(&self) -> DisplayCow<'_>

A Display for a Value as source code.
source§

fn type_name(&self) -> &'static str

Report the data type (generally for error reporting).
source§

fn query_state(&self, state: State) -> bool

Query the value’s state
source§

fn to_kstr(&self) -> KStringCow<'_>

Interpret as a string.
source§

fn to_value(&self) -> Value

Convert to an owned type.
source§

fn as_scalar(&self) -> Option<ScalarCow<'_>>

Extracts the scalar value if it is a scalar.
source§

fn is_scalar(&self) -> bool

Tests whether this value is a scalar
source§

fn as_array(&self) -> Option<&dyn ArrayView>

Extracts the array value if it is an array.
source§

fn is_array(&self) -> bool

Tests whether this value is an array
source§

fn as_object(&self) -> Option<&dyn ObjectView>

Extracts the object value if it is a object.
source§

fn is_object(&self) -> bool

Tests whether this value is an object
source§

fn as_state(&self) -> Option<State>

Extracts the state if it is one
source§

fn is_state(&self) -> bool

Tests whether this value is state
source§

fn is_nil(&self) -> bool

Tests whether this value is nil Read more
source§

impl Copy for DateTime

source§

impl Eq for DateTime

source§

impl StructuralEq for DateTime

source§

impl StructuralPartialEq for DateTime

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Any for Twhere T: Any,

source§

impl<T> CloneAny for Twhere T: Any + Clone,

source§

impl<T> CloneAnySend for Twhere T: Any + Send + Clone,

source§

impl<T> CloneAnySendSync for Twhere T: Any + Send + Sync + Clone,

source§

impl<T> CloneAnySync for Twhere T: Any + Sync + Clone,

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> RuleType for Twhere T: Copy + Debug + Eq + Hash + Ord,