Skip to main content

Time

Enum Time 

Source
pub enum Time {
    SecIndex(u32),
    Timestamp(u32),
    LocalTimestamp {
        timestamp: u32,
        local_offset_minutes: i16,
        season_offset_minutes: i16,
    },
}
Expand description

A point in time as SML encodes it: SML_Time.

Variants§

§

SecIndex(u32)

Seconds since an arbitrary, device-specific epoch (often power-up).

§

Timestamp(u32)

Seconds since 1970-01-01T00:00:00Z.

§

LocalTimestamp

A UTC timestamp with the local offsets the device applied.

Fields

§timestamp: u32

Seconds since 1970-01-01T00:00:00Z.

§local_offset_minutes: i16

Offset of local time from UTC, in minutes.

§season_offset_minutes: i16

Additional daylight-saving offset, in minutes.

Implementations§

Source§

impl Time

Source

pub const fn unix_seconds(self) -> Option<u32>

Seconds since 1970-01-01T00:00:00Z, for the two timestamp forms. A seconds index counts from a device-specific epoch and has no calendar time.

Source

pub fn write(&self, w: &mut Writer<'_>) -> Result<()>

Write the time with its choice tag.

Trait Implementations§

Source§

impl Clone for Time

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Time

Source§

impl Debug for Time

Source§

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

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

impl Display for Time

Timestamps as ISO 8601: 2023-11-14T22:13:20Z, or local wall time with its offset (2023-11-14T23:13:20+01:00); a seconds index as secIndex 42 s.

use sml_kit::Time;

assert_eq!(Time::Timestamp(1_700_000_000).to_string(), "2023-11-14T22:13:20Z");
let local = Time::LocalTimestamp { timestamp: 1_700_000_000, local_offset_minutes: 60, season_offset_minutes: 0 };
assert_eq!(local.to_string(), "2023-11-14T23:13:20+01:00");
Source§

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

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

impl Eq for Time

Source§

impl Hash for Time

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 PartialEq for Time

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Time

Auto Trait Implementations§

§

impl Forget for Time

§

impl Freeze for Time

§

impl Move for Time

§

impl RefUnwindSafe for Time

§

impl Send for Time

§

impl Sync for Time

§

impl Unpin for Time

§

impl UnsafeUnpin for Time

§

impl UnwindSafe for Time

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

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

fn try_from(value: U) -> Result<T, !>

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.