pub struct Timestamp(/* private fields */);Implementations§
Source§impl Timestamp
impl Timestamp
pub fn abs_diff(self, other: Timestamp) -> Duration
pub fn as_secs(self) -> u64
pub fn from_secs(value: u64) -> Self
pub fn as_secs_f64(self) -> f64
pub fn from_secs_f64(value: f64) -> Self
pub fn as_secs_f32(self) -> f32
pub fn from_secs_f32(value: f32) -> Self
pub fn as_micros(self) -> u128
pub fn from_micros(value: u64) -> Self
pub fn as_millis(self) -> u128
pub fn from_millis(value: u64) -> Self
pub fn as_nanos(self) -> u128
pub fn from_nanos(value: u64) -> Self
pub fn as_duration(self) -> Duration
Source§impl Timestamp
impl Timestamp
pub fn try_into_naivedatetime(self) -> Result<NaiveDateTime, Error>
pub fn try_into_datetime_local(self) -> Result<DateTime<Local>, Error>
pub fn try_into_datetime_utc(self) -> Result<DateTime<Utc>, Error>
Source§impl Timestamp
impl Timestamp
pub fn now_rounded() -> Self
pub fn elapsed(self) -> Result<Duration, Error>
pub fn duration_since(self, earlier: Self) -> Result<Duration, Error>
Sourcepub fn try_from_ansi_to_unix(self) -> Result<Self, Error>
pub fn try_from_ansi_to_unix(self) -> Result<Self, Error>
Converts between ANSI (Windows, 1601-01-01) and UNIX (1970-01-01) timestamps The source timestamp MUST be in nanoseconds (for Windows timestamp - multiply the source by 100)
§Example
use bma_ts::Timestamp;
let windows_timestamp = 133_575_013_473_650_000;
let unix_timestamp = Timestamp::from_nanos(windows_timestamp * 100)
.try_from_ansi_to_unix().unwrap();
assert_eq!(unix_timestamp.as_nanos(), 1_713_027_747_365_000_000);Sourcepub fn try_from_unix_to_ansi(self) -> Result<Self, Error>
pub fn try_from_unix_to_ansi(self) -> Result<Self, Error>
Converts between UNIX (1970-01-01) and ANSI (Windows, 1601-01-01) timestamps
The result timestamp is in nanoseconds (for Windows timestamp - divide the target by 100)
Trait Implementations§
Source§impl AddAssign<Duration> for Timestamp
impl AddAssign<Duration> for Timestamp
Source§fn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
Performs the
+= operation. Read moreSource§impl<'r> Decode<'r, Postgres> for Timestamp
impl<'r> Decode<'r, Postgres> for Timestamp
Source§fn decode(value: PgValueRef<'r>) -> Result<Self, BoxDynError>
fn decode(value: PgValueRef<'r>) -> Result<Self, BoxDynError>
Decode a new value of this type using a raw value from the database.
Source§impl<'r> Decode<'r, Sqlite> for Timestamp
impl<'r> Decode<'r, Sqlite> for Timestamp
Source§fn decode(value: SqliteValueRef<'r>) -> Result<Self, BoxDynError>
fn decode(value: SqliteValueRef<'r>) -> Result<Self, BoxDynError>
Decode a new value of this type using a raw value from the database.
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
Source§fn deserialize<D>(deserializer: D) -> Result<Timestamp, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Timestamp, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Encode<'_, Postgres> for Timestamp
impl Encode<'_, Postgres> for Timestamp
Source§fn encode_by_ref(
&self,
buf: &mut PgArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Send + Sync + 'static>>
fn encode_by_ref( &self, buf: &mut PgArgumentBuffer, ) -> Result<IsNull, Box<dyn Error + Send + Sync + 'static>>
fn size_hint(&self) -> usize
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
Writes the value of
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
Source§impl<'q> Encode<'q, Sqlite> for Timestamp
impl<'q> Encode<'q, Sqlite> for Timestamp
Source§fn encode_by_ref(
&self,
args: &mut Vec<SqliteArgumentValue<'q>>,
) -> Result<IsNull, Box<dyn Error + Send + Sync + 'static>>
fn encode_by_ref( &self, args: &mut Vec<SqliteArgumentValue<'q>>, ) -> Result<IsNull, Box<dyn Error + Send + Sync + 'static>>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
Writes the value of
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
Source§impl PgHasArrayType for Timestamp
impl PgHasArrayType for Timestamp
fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Source§impl SubAssign<Duration> for Timestamp
impl SubAssign<Duration> for Timestamp
Source§fn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
Performs the
-= operation. Read moreSource§impl TryFrom<NaiveDateTime> for Timestamp
impl TryFrom<NaiveDateTime> for Timestamp
Source§impl TryFrom<Timestamp> for NaiveDateTime
impl TryFrom<Timestamp> for NaiveDateTime
Source§impl Type<Postgres> for Timestamp
impl Type<Postgres> for Timestamp
Source§fn type_info() -> PgTypeInfo
fn type_info() -> PgTypeInfo
Returns the canonical SQL type for this Rust type. Read more
Source§fn compatible(ty: &PgTypeInfo) -> bool
fn compatible(ty: &PgTypeInfo) -> bool
Determines if this Rust type is compatible with the given SQL type. Read more
Source§impl Type<Sqlite> for Timestamp
impl Type<Sqlite> for Timestamp
Source§fn type_info() -> SqliteTypeInfo
fn type_info() -> SqliteTypeInfo
Returns the canonical SQL type for this Rust type. Read more
Source§fn compatible(ty: &SqliteTypeInfo) -> bool
fn compatible(ty: &SqliteTypeInfo) -> bool
Determines if this Rust type is compatible with the given SQL type. Read more
impl Copy for Timestamp
impl Eq for Timestamp
impl StructuralPartialEq for Timestamp
Auto Trait Implementations§
impl Freeze for Timestamp
impl RefUnwindSafe for Timestamp
impl Send for Timestamp
impl Sync for Timestamp
impl Unpin for Timestamp
impl UnwindSafe for Timestamp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more