Skip to main content

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 to_rfc3339(&self) -> String

Returns an RFC 3339 and ISO 8601 date and time string such as 1996-12-19T16:39:57-08:00.

Source

pub fn parse_from_rfc3339(s: &str) -> Result<DateTime, ParseError>

Parses an RFC 3339 and ISO 8601 date and time string such as 1996-12-19T16:39:57-08:00, then returns a new DateTime

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 BinaryDecodable for DateTime

Source§

fn decode<S>(stream: &mut S, ctx: &Context<'_>) -> Result<DateTime, Error>
where S: Read + ?Sized,

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§

impl BinaryEncodable for DateTime

DateTime encoded as 64-bit signed int

Source§

fn byte_len(&self, _ctx: &Context<'_>) -> 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, _ctx: &Context<'_>) -> Result<(), Error>
where S: Write + ?Sized,

Encodes the instance to the write stream.
Source§

fn override_encoding(&self) -> Option<BuiltInDataEncoding>

Override the extension object encoding used for this type. This only makes sense if the type can only ever be encoded using a single built-in encoding.
Source§

fn encode_to_vec(&self, ctx: &Context<'_>) -> Vec<u8>

Convenience method for encoding a message straight into an array of bytes. It is preferable to reuse buffers than to call this so it should be reserved for tests and trivial code.
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 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 DateTime<Utc>

Source§

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

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 = ParseError

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 IntoVariant for Box<DateTime>

Source§

fn into_variant(self) -> Variant

Convert self into a variant.
Source§

impl IntoVariant for DateTime

Source§

fn into_variant(self) -> Variant

Convert self into a variant.
Source§

impl JsonDecodable for DateTime

Source§

fn decode( stream: &mut JsonStreamReader<&mut dyn Read>, _ctx: &Context<'_>, ) -> Result<DateTime, Error>

Decode Self from a JSON stream.
Source§

impl JsonEncodable for DateTime

Source§

fn encode( &self, stream: &mut JsonStreamWriter<&mut dyn Write>, _ctx: &Context<'_>, ) -> Result<(), Error>

Write the type to the provided JSON writer.
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) -> Self
where Self: Sized,

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
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 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 TryFromVariant for DateTime

Source§

fn try_from_variant(v: Variant) -> Result<DateTime, Error>

Try to cast the given variant to this type.
Source§

impl UaNullable for DateTime

Source§

fn is_ua_null(&self) -> bool

Return true if this value is null, meaning it can be left out when being encoded in JSON and XML encodings.
Source§

impl VariantType for DateTime

Source§

fn variant_type_id() -> VariantScalarTypeId

The variant kind this type will be represented as.
Source§

impl XmlDecodable for DateTime

Source§

fn decode( read: &mut XmlStreamReader<&mut dyn Read>, _context: &Context<'_>, ) -> Result<DateTime, Error>

Decode a value from an XML stream.
Source§

impl XmlEncodable for DateTime

Source§

fn encode( &self, writer: &mut XmlStreamWriter<&mut dyn Write>, context: &Context<'_>, ) -> Result<(), Error>

Encode a value to an XML stream.
Source§

impl XmlType for DateTime

Source§

const TAG: &'static str = "DateTime"

The static fallback tag for this type. Convenience feature, but also used in nested types.
Source§

fn tag(&self) -> &str

The XML tag name for this type.
Source§

impl Copy for DateTime

Source§

impl Eq 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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> EventField for T
where T: IntoVariant + Clone,

Source§

fn get_value( &self, attribute_id: AttributeId, index_range: &NumericRange, remaining_path: &[QualifiedName], ) -> Variant

Get the variant representation of this field, using the given index range. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoAnyArc for T
where T: Send + Sync + 'static,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Upcast to Arc<dyn Any>.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more