DateTime

Struct DateTime 

Source
pub struct DateTime { /* private fields */ }
Expand description

A date/time value. This is a wrapper around the chrono type with extra functionality for obtaining ticks in OPC UA measurements, endtimes, epoch etc.

Implementations§

Source§

impl DateTime

Source

pub fn now() -> DateTime

Constructs from the current time

Source

pub fn now_with_offset(offset: TimeDelta) -> DateTime

Constructs from the current time with an offset

Source

pub fn null() -> DateTime

Creates a null date time (i.e. the epoch)

Source

pub fn is_null(&self) -> bool

Tests if the date time is null (i.e. equal to epoch)

Source

pub fn epoch() -> DateTime

Constructs a date time for the epoch

Source

pub fn endtimes() -> DateTime

Constructs a date time for the endtimes

Source

pub fn endtimes_ticks() -> i64

Returns the maximum tick value, corresponding to the end of time

Source

pub fn ymd(year: u16, month: u16, day: u16) -> DateTime

Constructs from a year, month, day

Source

pub fn ymd_hms( year: u16, month: u16, day: u16, hour: u16, minute: u16, second: u16, ) -> DateTime

Constructs from a year, month, day, hour, minute, second

Source

pub fn ymd_hms_nano( year: u16, month: u16, day: u16, hour: u16, minute: u16, second: u16, nanos: u32, ) -> DateTime

Constructs from a year, month, day, hour, minute, second, nanosecond

Source

pub fn ticks(&self) -> i64

Returns the time in ticks, of 100 nanosecond intervals

Source

pub fn checked_ticks(&self) -> i64

To checked ticks. Function returns 0 or MAX_INT64 if date exceeds valid OPC UA range

Source

pub fn as_chrono(&self) -> DateTime<Utc>

Time as chrono

Trait Implementations§

Source§

impl Add<TimeDelta> for DateTime

Source§

type Output = DateTime

The resulting type after applying the + operator.
Source§

fn add(self, duration: TimeDelta) -> DateTime

Performs the + operation. Read more
Source§

impl BinaryEncoder<DateTime> for DateTime

DateTime encoded as 64-bit signed int

Source§

fn byte_len(&self) -> usize

Returns the exact byte length of the structure as it would be if encode were called. This may be called prior to writing to ensure the correct amount of space is available.
Source§

fn encode<S>(&self, stream: &mut S) -> Result<usize, StatusCode>
where S: Write,

Encodes the instance to the write stream.
Source§

fn decode<S>( stream: &mut S, decoding_options: &DecodingOptions, ) -> Result<DateTime, StatusCode>
where S: Read,

Decodes an instance from the read stream. The decoding options contains restrictions set by the server / client on the length of strings, arrays etc. If these limits are exceeded the implementation should return with a BadDecodingError as soon as possible.
Source§

fn encode_to_vec(&self) -> Vec<u8>

Source§

impl Clone for DateTime

Source§

fn clone(&self) -> DateTime

Returns a duplicate 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<(), Error>

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

impl Default for DateTime

Source§

fn default() -> DateTime

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

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

Source§

fn deserialize<D>( deserializer: D, ) -> Result<DateTime, <D as Deserializer<'de>>::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<(), Error>

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

impl From<(u16, u16, u16, u16, u16, u16)> for DateTime

Source§

fn from(dt: (u16, u16, u16, u16, u16, u16)) -> DateTime

Converts to this type from the input type.
Source§

impl From<(u16, u16, u16, u16, u16, u16, u32)> for DateTime

Source§

fn from(dt: (u16, u16, u16, u16, u16, u16, u32)) -> DateTime

Converts to this type from the input type.
Source§

impl From<DateTime<Utc>> for DateTime

Source§

fn from(date_time: DateTime<Utc>) -> DateTime

Converts to this type from the input type.
Source§

impl From<DateTime> for DataValue

Source§

fn from(v: DateTime) -> DataValue

Converts to this type from the input type.
Source§

impl From<DateTime> for Variant

Source§

fn from(v: DateTime) -> Variant

Converts to this type from the input type.
Source§

impl From<i64> for DateTime

Source§

fn from(value: i64) -> DateTime

Converts to this type from the input type.
Source§

impl FromStr for DateTime

Source§

type Err = ()

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<DateTime, <DateTime as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Into<DateTime<Utc>> for DateTime

Source§

fn into(self) -> DateTime<Utc>

Converts this type into the (usually inferred) input type.
Source§

impl Into<i64> for DateTime

Source§

fn into(self) -> i64

Converts this type into the (usually inferred) input type.
Source§

impl PartialEq for DateTime

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd 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

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

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

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

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 as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

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

impl Sub<TimeDelta> for DateTime

Source§

type Output = DateTime

The resulting type after applying the - operator.
Source§

fn sub(self, duration: TimeDelta) -> DateTime

Performs the - operation. Read more
Source§

impl Sub for DateTime

Source§

type Output = TimeDelta

The resulting type after applying the - operator.
Source§

fn sub(self, other: DateTime) -> TimeDelta

Performs the - operation. Read more
Source§

impl Copy for DateTime

Source§

impl StructuralPartialEq for DateTime

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,