pub struct Timestamp(/* private fields */);Expand description
Unix timestamp representing seconds since the Unix epoch (January 1, 1970 00:00:00 UTC)
Internally stored as an i64, this type provides convenient methods for working
with timestamps in ForgeDB schemas.
§Examples
use forgedb_types::Timestamp;
// Create from current time
let now = Timestamp::now();
// Create from seconds
let ts = Timestamp::from_seconds(1234567890);
// Get underlying value
let seconds = ts.as_seconds();Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub fn from_seconds(seconds: i64) -> Self
pub fn from_seconds(seconds: i64) -> Self
Creates a new timestamp from seconds since Unix epoch
§Examples
use forgedb_types::Timestamp;
let ts = Timestamp::from_seconds(1234567890);
assert_eq!(ts.as_seconds(), 1234567890);Sourcepub fn now() -> Self
pub fn now() -> Self
Returns the current timestamp
§Examples
use forgedb_types::Timestamp;
let now = Timestamp::now();
assert!(now.as_seconds() > 0);Sourcepub fn as_seconds(&self) -> i64
pub fn as_seconds(&self) -> i64
Returns the timestamp as seconds since Unix epoch
§Examples
use forgedb_types::Timestamp;
let ts = Timestamp::from_seconds(1234567890);
assert_eq!(ts.as_seconds(), 1234567890);Trait Implementations§
impl Copy for Timestamp
Source§impl<'de> Deserialize<'de> for Timestamp
impl<'de> Deserialize<'de> for Timestamp
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Timestamp
Source§impl Ord for Timestamp
impl Ord for Timestamp
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Timestamp
impl PartialOrd 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 UnsafeUnpin 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