Struct scrypto_test::prelude::UtcDateTime
source · pub struct UtcDateTime { /* private fields */ }Expand description
A UtcDateTime represents a Unix timestamp on the UTC Calendar.
It can represent any date between 1-1-1 00:00:00 and [u32::MAX]-12-31 23:59:59 (inclusive).
In terms of indexing:
- Months and days of month are 1-based (i.e.
Dec 15th 2022corresponds to2022-12-15). - Hour, minute and second are 0-based, based on the 24-hour clock.
Midnight is represented as
00:00:00and23:59:59is the last second before midnight. Following Unix timstamp conventions, leap seconds are not supported.
UtcDateTime supports methods for easy conversion to and from the Instant type, which
can be queried from the Radix Engine.
Implementations§
source§impl UtcDateTime
impl UtcDateTime
sourcepub fn new(
year: u32,
month: u8,
day_of_month: u8,
hour: u8,
minute: u8,
second: u8
) -> Result<UtcDateTime, DateTimeError>
pub fn new( year: u32, month: u8, day_of_month: u8, hour: u8, minute: u8, second: u8 ) -> Result<UtcDateTime, DateTimeError>
Creates a UtcDateTime from its individual components.
Months and days of month are 1-based, with the following limits:
- Valid year range is:
1tou32::MAXinclusive. - Valid month values are:
1to12inclusive. - Valid day of month values are:
1to{28, 29, 30, 31}inclusive. The upper limit depends on the month and year, as per the Gregorian calendar.
An attempt to create an invalid date (e.g. 2022-04-31 or 2023-02-29)
will result in a corresponding Err(DateTimeError).
Hour, minute and second constitute a 0-based 24-hour clock.
Midnight is represented as 00:00:00 and 23:59:59 is the maximum possible time (a second before midnight).
Following Unix time conventions, leap seconds are not represented in this system.
sourcepub fn from_instant(instant: &Instant) -> Result<UtcDateTime, DateTimeError>
pub fn from_instant(instant: &Instant) -> Result<UtcDateTime, DateTimeError>
Creates a UtcDateTime from an Instant.
The minimum supported seconds_since_unix_epoch value is -62135596800 (corresponding to 1-1-1 00:00:00)
and the maximum value is 135536014634284799 (corresponding to [u32::Max]-12-31 23:59:59).
sourcepub fn to_instant(&self) -> Instant
pub fn to_instant(&self) -> Instant
Creates an Instant from this UtcDateTime
pub fn year(&self) -> u32
pub fn month(&self) -> u8
pub fn day_of_month(&self) -> u8
pub fn hour(&self) -> u8
pub fn minute(&self) -> u8
pub fn second(&self) -> u8
pub fn add_days(&self, days_to_add: i64) -> Option<UtcDateTime>
pub fn add_hours(&self, hours_to_add: i64) -> Option<UtcDateTime>
pub fn add_minutes(&self, minutes_to_add: i64) -> Option<UtcDateTime>
pub fn add_seconds(&self, seconds_to_add: i64) -> Option<UtcDateTime>
Trait Implementations§
source§impl<X> Categorize<X> for UtcDateTimewhere
X: CustomValueKind,
impl<X> Categorize<X> for UtcDateTimewhere
X: CustomValueKind,
fn value_kind() -> ValueKind<X>
source§impl Clone for UtcDateTime
impl Clone for UtcDateTime
source§fn clone(&self) -> UtcDateTime
fn clone(&self) -> UtcDateTime
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for UtcDateTime
impl Debug for UtcDateTime
source§impl<D, X> Decode<X, D> for UtcDateTimewhere
D: Decoder<X>,
X: CustomValueKind,
impl<D, X> Decode<X, D> for UtcDateTimewhere
D: Decoder<X>,
X: CustomValueKind,
source§fn decode_body_with_value_kind(
decoder: &mut D,
value_kind: ValueKind<X>
) -> Result<UtcDateTime, DecodeError>
fn decode_body_with_value_kind( decoder: &mut D, value_kind: ValueKind<X> ) -> Result<UtcDateTime, DecodeError>
source§impl Describe<NoCustomTypeKind> for UtcDateTime
impl Describe<NoCustomTypeKind> for UtcDateTime
source§const TYPE_ID: RustTypeId = _
const TYPE_ID: RustTypeId = _
TYPE_ID should give a unique identifier for its SBOR schema type.
An SBOR schema type capture details about the SBOR payload, how it should be interpreted, validated and displayed. Read moresource§fn type_data() -> TypeData<NoCustomTypeKind, RustTypeId>
fn type_data() -> TypeData<NoCustomTypeKind, RustTypeId>
source§fn add_all_dependencies(aggregator: &mut TypeAggregator<NoCustomTypeKind>)
fn add_all_dependencies(aggregator: &mut TypeAggregator<NoCustomTypeKind>)
get_local_type_data, we need to ensure that the type and all of its own references
get added to the aggregator. Read moresource§impl Describe<ScryptoCustomTypeKind> for UtcDateTime
impl Describe<ScryptoCustomTypeKind> for UtcDateTime
source§const TYPE_ID: RustTypeId = _
const TYPE_ID: RustTypeId = _
TYPE_ID should give a unique identifier for its SBOR schema type.
An SBOR schema type capture details about the SBOR payload, how it should be interpreted, validated and displayed. Read moresource§fn type_data() -> TypeData<ScryptoCustomTypeKind, RustTypeId>
fn type_data() -> TypeData<ScryptoCustomTypeKind, RustTypeId>
source§fn add_all_dependencies(aggregator: &mut TypeAggregator<C>)
fn add_all_dependencies(aggregator: &mut TypeAggregator<C>)
get_local_type_data, we need to ensure that the type and all of its own references
get added to the aggregator. Read moresource§impl Display for UtcDateTime
impl Display for UtcDateTime
source§impl<E, X> Encode<X, E> for UtcDateTimewhere
E: Encoder<X>,
X: CustomValueKind,
impl<E, X> Encode<X, E> for UtcDateTimewhere
E: Encoder<X>,
X: CustomValueKind,
source§fn encode_value_kind(&self, encoder: &mut E) -> Result<(), EncodeError>
fn encode_value_kind(&self, encoder: &mut E) -> Result<(), EncodeError>
source§fn encode_body(&self, encoder: &mut E) -> Result<(), EncodeError>
fn encode_body(&self, encoder: &mut E) -> Result<(), EncodeError>
source§impl From<UtcDateTime> for Instant
impl From<UtcDateTime> for Instant
source§fn from(dt: UtcDateTime) -> Instant
fn from(dt: UtcDateTime) -> Instant
source§impl FromStr for UtcDateTime
impl FromStr for UtcDateTime
§type Err = ParseUtcDateTimeError
type Err = ParseUtcDateTimeError
source§fn from_str(s: &str) -> Result<UtcDateTime, <UtcDateTime as FromStr>::Err>
fn from_str(s: &str) -> Result<UtcDateTime, <UtcDateTime as FromStr>::Err>
s to return a value of this type. Read moresource§impl Hash for UtcDateTime
impl Hash for UtcDateTime
source§impl Ord for UtcDateTime
impl Ord for UtcDateTime
source§fn cmp(&self, other: &UtcDateTime) -> Ordering
fn cmp(&self, other: &UtcDateTime) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for UtcDateTime
impl PartialEq for UtcDateTime
source§fn eq(&self, other: &UtcDateTime) -> bool
fn eq(&self, other: &UtcDateTime) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for UtcDateTime
impl PartialOrd for UtcDateTime
source§fn partial_cmp(&self, other: &UtcDateTime) -> Option<Ordering>
fn partial_cmp(&self, other: &UtcDateTime) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl<X> SborTuple<X> for UtcDateTimewhere
X: CustomValueKind,
impl<X> SborTuple<X> for UtcDateTimewhere
X: CustomValueKind,
fn get_length(&self) -> usize
source§impl TryFrom<Instant> for UtcDateTime
impl TryFrom<Instant> for UtcDateTime
§type Error = DateTimeError
type Error = DateTimeError
source§fn try_from(
instant: Instant
) -> Result<UtcDateTime, <UtcDateTime as TryFrom<Instant>>::Error>
fn try_from( instant: Instant ) -> Result<UtcDateTime, <UtcDateTime as TryFrom<Instant>>::Error>
impl Copy for UtcDateTime
impl Eq for UtcDateTime
impl StructuralPartialEq for UtcDateTime
Auto Trait Implementations§
impl Freeze for UtcDateTime
impl RefUnwindSafe for UtcDateTime
impl Send for UtcDateTime
impl Sync for UtcDateTime
impl Unpin for UtcDateTime
impl UnwindSafe for UtcDateTime
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more