pub struct Timestamp { /* private fields */ }Expand description
Implementations§
Source§impl Timestamp
impl Timestamp
Sourcepub const MAX_REPRESENTABLE_DATE_TIME: DateTime
pub const MAX_REPRESENTABLE_DATE_TIME: DateTime
The maximum DateTime that can be represented as Timestamp.
use leap_seconds::{Date, DateTime, Time, Timestamp};
let alt_max_1 = DateTime {
date: Date::new(584_554_051_153, 11, 9)?,
time: Time::new(7, 0, 15)?,
};
let alt_max_2 = Timestamp::from_u64(u64::MAX).date_time();
assert_eq!(Timestamp::MAX_REPRESENTABLE_DATE_TIME, alt_max_1);
assert_eq!(Timestamp::MAX_REPRESENTABLE_DATE_TIME, alt_max_2);Sourcepub const MIN_REPRESENTABLE_DATE_TIME: DateTime
pub const MIN_REPRESENTABLE_DATE_TIME: DateTime
The minimum DateTime that can be represented as Timestamp.
use leap_seconds::{Date, DateTime, Time, Timestamp};
let alt_min_1 = DateTime {
date: Date::new(1900, 1, 1)?,
time: Time::new(0, 0, 0)?,
};
let alt_min_2 = Timestamp::from_u64(0).date_time();
assert_eq!(Timestamp::MIN_REPRESENTABLE_DATE_TIME, alt_min_1);
assert_eq!(Timestamp::MIN_REPRESENTABLE_DATE_TIME, alt_min_2);Sourcepub fn from_date_time(
date_time: DateTime,
) -> Result<Self, DateTimeNotRepresentable>
pub fn from_date_time( date_time: DateTime, ) -> Result<Self, DateTimeNotRepresentable>
Creates a new Timestamp from a DateTime.
§Errors
Fails if the DateTime is not representable as a Timestamp.
use leap_seconds::{Date, DateTime, Time, Timestamp};
let error = Timestamp::from_date_time(DateTime {
date: Date::new(1899, 1, 1).expect("valid date"),
time: Time::new(12, 0, 0).expect("valid time"),
});
assert!(error.is_err());Trait Implementations§
Source§impl Ord for Timestamp
impl Ord for Timestamp
Source§impl PartialOrd for Timestamp
impl PartialOrd for Timestamp
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