Skip to main content

TimestampLike

Trait TimestampLike 

Source
pub trait TimestampLike:
    Clone
    + PartialOrd
    + Add<Duration, Output = Self>
    + Sub<Duration, Output = Self>
    + Sub<Output = Duration>
    + for<'a> TryInto<Datum<'a>, Error = TimestampError>
    + for<'a> TryFrom<Datum<'a>, Error = ()>
    + TimeLike
    + DateLike {
Show 28 methods // Required methods fn new(date: NaiveDate, time: NaiveTime) -> Self; fn timestamp(&self) -> i64; fn timestamp_subsec_micros(&self) -> u32; fn date(&self) -> NaiveDate; fn date_time(&self) -> NaiveDateTime; fn from_date_time(dt: NaiveDateTime) -> Self; fn timezone_offset(&self) -> &'static str; fn timezone_hours(&self) -> &'static str; fn timezone_minutes(&self) -> &'static str; fn timezone_name(&self, caps: bool) -> &'static str; fn checked_add_signed(self, rhs: Duration) -> Option<Self>; fn checked_sub_signed(self, rhs: Duration) -> Option<Self>; // Provided methods fn weekday0(&self) -> usize { ... } fn iso_year_ce(&self) -> u32 { ... } fn extract_epoch<T>(&self) -> T where T: DecimalLike { ... } fn truncate_microseconds(&self) -> Self { ... } fn truncate_milliseconds(&self) -> Self { ... } fn truncate_second(&self) -> Self { ... } fn truncate_minute(&self) -> Self { ... } fn truncate_hour(&self) -> Self { ... } fn truncate_day(&self) -> Self { ... } fn truncate_week(&self) -> Result<Self, TimestampError> { ... } fn truncate_month(&self) -> Self { ... } fn truncate_quarter(&self) -> Self { ... } fn truncate_year(&self) -> Self { ... } fn truncate_decade(&self) -> Self { ... } fn truncate_century(&self) -> Self { ... } fn truncate_millennium(&self) -> Self { ... }
}
Expand description

A timestamp with both a date and a time component, but not necessarily a timezone component.

Required Methods§

Source

fn new(date: NaiveDate, time: NaiveTime) -> Self

Source

fn timestamp(&self) -> i64

Source

fn timestamp_subsec_micros(&self) -> u32

Source

fn date(&self) -> NaiveDate

Return the date component of the timestamp

Source

fn date_time(&self) -> NaiveDateTime

Return the date and time of the timestamp

Source

fn from_date_time(dt: NaiveDateTime) -> Self

Return the date and time of the timestamp

Source

fn timezone_offset(&self) -> &'static str

Returns a string representing the timezone’s offset from UTC.

Source

fn timezone_hours(&self) -> &'static str

Returns a string representing the hour portion of the timezone’s offset from UTC.

Source

fn timezone_minutes(&self) -> &'static str

Returns a string representing the minute portion of the timezone’s offset from UTC.

Source

fn timezone_name(&self, caps: bool) -> &'static str

Returns the abbreviated name of the timezone with the specified capitalization.

Source

fn checked_add_signed(self, rhs: Duration) -> Option<Self>

Adds given Duration to the current date and time.

Source

fn checked_sub_signed(self, rhs: Duration) -> Option<Self>

Subtracts given Duration from the current date and time.

Provided Methods§

Source

fn weekday0(&self) -> usize

Returns the weekday as a usize between 0 and 6, where 0 represents Sunday and 6 represents Saturday.

Source

fn iso_year_ce(&self) -> u32

Like chrono::Datelike::year_ce, but works on the ISO week system.

Source

fn extract_epoch<T>(&self) -> T
where T: DecimalLike,

Source

fn truncate_microseconds(&self) -> Self

Source

fn truncate_milliseconds(&self) -> Self

Source

fn truncate_second(&self) -> Self

Source

fn truncate_minute(&self) -> Self

Source

fn truncate_hour(&self) -> Self

Source

fn truncate_day(&self) -> Self

Source

fn truncate_week(&self) -> Result<Self, TimestampError>

Source

fn truncate_month(&self) -> Self

Source

fn truncate_quarter(&self) -> Self

Source

fn truncate_year(&self) -> Self

Source

fn truncate_decade(&self) -> Self

Source

fn truncate_century(&self) -> Self

Source

fn truncate_millennium(&self) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TimestampLike for DateTime<Utc>

Source§

fn new(date: NaiveDate, time: NaiveTime) -> Self

Source§

fn date(&self) -> NaiveDate

Source§

fn date_time(&self) -> NaiveDateTime

Source§

fn from_date_time(dt: NaiveDateTime) -> Self

Source§

fn timestamp(&self) -> i64

Source§

fn timestamp_subsec_micros(&self) -> u32

Source§

fn timezone_offset(&self) -> &'static str

Source§

fn timezone_hours(&self) -> &'static str

Source§

fn timezone_minutes(&self) -> &'static str

Source§

fn timezone_name(&self, caps: bool) -> &'static str

Source§

fn checked_add_signed(self, rhs: Duration) -> Option<Self>

Source§

fn checked_sub_signed(self, rhs: Duration) -> Option<Self>

Source§

impl TimestampLike for NaiveDateTime

Source§

fn new(date: NaiveDate, time: NaiveTime) -> Self

Source§

fn date(&self) -> NaiveDate

Source§

fn date_time(&self) -> NaiveDateTime

Source§

fn from_date_time(dt: NaiveDateTime) -> NaiveDateTime

Source§

fn timestamp(&self) -> i64

Source§

fn timestamp_subsec_micros(&self) -> u32

Source§

fn timezone_offset(&self) -> &'static str

Source§

fn timezone_hours(&self) -> &'static str

Source§

fn timezone_minutes(&self) -> &'static str

Source§

fn timezone_name(&self, _caps: bool) -> &'static str

Source§

fn checked_add_signed(self, rhs: Duration) -> Option<Self>

Source§

fn checked_sub_signed(self, rhs: Duration) -> Option<Self>

Implementors§