DateTimeExt

Trait DateTimeExt 

Source
pub trait DateTimeExt {
    // Required methods
    fn now() -> Self;
    fn to_unix_timestamp(&self) -> i64;
    fn from_unix_timestamp(secs: i64) -> Self;
}
Expand description

Extension trait for SQL datetime operations.

This trait provides a unified API for datetime operations regardless of whether chrono or time feature is enabled.

Required Methods§

Source

fn now() -> Self

Returns the current UTC datetime.

Source

fn to_unix_timestamp(&self) -> i64

Returns the Unix timestamp (seconds since epoch).

Source

fn from_unix_timestamp(secs: i64) -> Self

Creates a datetime from Unix timestamp (seconds since epoch).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl DateTimeExt for DateTime

Available on crate feature chrono and non-crate feature time only.