Struct TimeSecond

pub struct TimeSecond { /* private fields */ }

Represents a single point in a civil day, to second precision.

Implementations

impl TimeSecond

const fn new(second: i32) -> Result<TimeSecond, RangeError>

Creates a new civil time from a given second value.

The value must correspond to the number of seconds elapsed since the start of a civil day. It cannot exceed the length of a civil day (in seconds).

const fn constant(second: i32) -> TimeSecond

Creates a new civil time from a given second value.

This panics when second exceeds the maximum number of seconds in a single civil day.

const fn second(self) -> i32

Returns the second value.

The value returned is guaranteed to be in the range specified by CivilDaySecond.

const fn overflowing_add(self, seconds: i32) -> Result<(TimeSecond, i32), RangeError>

Adds the given number of seconds to this civil time and returns the resulting civil time with any overflowing amount in units of civil days.

This returns an error when integer overflow occurs. For example, when seconds is i32::MAX and this civil time is any time other than midnight.

Note that the number of days returned may exceed the range supported by UnixEpochDay. Moreover, the number of days returned may be negative. This occurs only when seconds is negative enough to result in the time wrapping around at 0.

const fn to_time(&self) -> Time

Converts this second representation of a civil time into the components of a civil time.

The subsecond component on the Time returned is always 0.

Trait Implementations

impl Clone for TimeSecond

fn clone(&self) -> TimeSecond

impl Copy for TimeSecond

impl Debug for TimeSecond

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

impl Eq for TimeSecond

impl Ord for TimeSecond

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

impl PartialEq for TimeSecond

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

impl PartialOrd for TimeSecond

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

impl StructuralPartialEq for TimeSecond

Auto Trait Implementations

impl Freeze for TimeSecond

impl RefUnwindSafe for TimeSecond

impl Send for TimeSecond

impl Sync for TimeSecond

impl Unpin for TimeSecond

impl UnsafeUnpin for TimeSecond

impl UnwindSafe for TimeSecond

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for TimeSecond

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for TimeSecond where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for TimeSecond where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

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

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

impl<T, U> TryInto<U> for TimeSecond where U: TryFrom<T>,

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