pub struct DateTime {
pub date: Date,
pub time: Time,
}Expand description
A day and a time of day, without a time zone.
Fields§
§date: Date§time: TimeImplementations§
Source§impl DateTime
impl DateTime
pub const fn new(date: Date, time: Time) -> DateTime
Sourcepub fn now_local() -> DateTime
pub fn now_local() -> DateTime
Now, in the local zone, summer time included.
use rich_interact::datetime::DateTime;
assert!(DateTime::now_local().is_valid());Sourcepub fn from_unix(unix: i64, zone: &Zone) -> DateTime
pub fn from_unix(unix: i64, zone: &Zone) -> DateTime
The moment unix (seconds since 1970-01-01 00:00 UTC) on zone’s
clocks.
use rich_interact::datetime::{Date, DateTime, Time, Zone};
let at = DateTime::from_unix(1_792_404_000, &Zone::Fixed(7200));
assert_eq!(at, DateTime::new(Date::new(2026, 10, 19), Time::new(12, 0, 0)));
assert_eq!(at.to_unix(&Zone::Fixed(7200)), 1_792_404_000);Sourcepub fn to_unix(self, zone: &Zone) -> i64
pub fn to_unix(self, zone: &Zone) -> i64
The moment this is on zone’s clocks, in seconds since 1970 UTC.
A time the clocks pass twice (when summer time ends) is the first
of the two; one they skip (when it starts) is read on the clock of
before the change, so 02:30 in a gap from 02:00 to 03:00 is 03:30.
Sourcepub fn add_seconds(self, seconds: i64) -> DateTime
pub fn add_seconds(self, seconds: i64) -> DateTime
The moment seconds later (earlier if negative), on a clock that
does not change (as UTC’s): add to to_unix for
a zone’s.
Trait Implementations§
impl Copy for DateTime
impl Eq for DateTime
Source§impl Ord for DateTime
impl Ord for DateTime
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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for DateTime
impl PartialOrd for DateTime
impl StructuralPartialEq for DateTime
Auto Trait Implementations§
impl Freeze for DateTime
impl RefUnwindSafe for DateTime
impl Send for DateTime
impl Sync for DateTime
impl Unpin for DateTime
impl UnsafeUnpin for DateTime
impl UnwindSafe for DateTime
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§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<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more