Skip to main content

Timestamp

Struct Timestamp 

Source
#[repr(C)]
pub struct Timestamp { pub year_from_1970: u8, pub month: u8, pub days: u8, pub hours: u8, pub minutes: u8, pub seconds: u8, }
Expand description

Describes an instant in time. The system only supports local time and has no concept of time zones.

Fields§

§year_from_1970: u8

The Gregorian calendar year, minus 1970 (so 10 is 1980, and 30 is the year 2000)

§month: u8

The month of the year, where January is 1 and December is 12

§days: u8

The day of the month where 1 is the first of the month, through to 28, 29, 30 or 31 (as appropriate)

§hours: u8

The hour in the day, from 0 to 23

§minutes: u8

The minutes past the hour, from 0 to 59

§seconds: u8

The seconds past the minute, from 0 to 59. Note that some filesystems only have 2-second precision on their timestamps.

Implementations§

Source§

impl Timestamp

Source

pub fn day_of_week(&self) -> DayOfWeek

Returns the day of the week for the given timestamp.

Source

pub fn increment(&mut self, days: u32, seconds: u32)

Move this timestamp forward by a number of days and seconds.

Source

pub fn is_leap_year(&self) -> bool

Returns true if this is a leap year, false otherwise.

Source

pub fn days_in_month(&self) -> u8

Returns the number of days in the current month

Source

pub fn month_str(&self) -> &'static str

Returns the current month as a UK English string (e.g. “August”).

Trait Implementations§

Source§

impl Clone for Timestamp

Source§

fn clone(&self) -> Timestamp

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 Debug for Timestamp

Source§

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

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

impl Display for Timestamp

Source§

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

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

impl Eq for Timestamp

Source§

impl PartialEq for Timestamp

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for Timestamp

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, 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.