pub struct CalendarDate(/* private fields */);Expand description
A calendar day, which is the only temporal resolution a rate table has.
A thin wrapper over jiff::civil::Date so the crate’s public surface (and the
py/js bindings behind it) keeps its own type. The wrapped crate replaced a
hand-rolled proleptic-Gregorian day-number implementation (issue #91); the pinned
tests that held that implementation to Python’s datetime now hold jiff to the
same three known values.
Implementations§
Source§impl CalendarDate
impl CalendarDate
Sourcepub const fn from_ymd(year: i32, month: u32, day: u32) -> CalendarDate
pub const fn from_ymd(year: i32, month: u32, day: u32) -> CalendarDate
A date from its parts, for the literals in this file.
const so pinned_rates can pin its retrieval date. jiff’s constant
refuses an invalid literal at compile time when const-evaluated, which is
strictly better than the old non-validating constructor; anything arriving
at runtime goes through CalendarDate::try_from_ymd.
Sourcepub fn try_from_ymd(
year: i32,
month: u32,
day: u32,
) -> Result<CalendarDate, Error>
pub fn try_from_ymd( year: i32, month: u32, day: u32, ) -> Result<CalendarDate, Error>
A date from parts that came from outside this crate.
The S2 boundary: a --today flag or a JSON field is three integers, and
2026-02-30 would otherwise produce a day number for March 2nd and an age
two days out. The range pre-checks keep the narrowing casts from wrapping
(month = 257 must not arrive at jiff as 1).
Sourcepub fn from_unix_secs(secs: u64) -> Result<CalendarDate, Error>
pub fn from_unix_secs(secs: u64) -> Result<CalendarDate, Error>
The UTC civil day secs seconds after the Unix epoch falls on.
UTC rather than local, and no tzdb: a rate table’s age is measured in
ninety-day units, so the zone can only ever move the answer by a day. The time
is the caller’s: this crate doesn’t read the clock (ARCH-6), and
microvms_core::prelude::CalendarDateExt::today_utc is the one that does.
Refuses a time past 9999-12-31, the last day the calendar holds, rather than clamping it: the likeliest such value is a millisecond count passed as seconds, and an age computed from a clamped or defaulted date would be wrong with no sign.
pub fn year(self) -> i32
pub fn month(self) -> u32
pub fn day(self) -> u32
Sourcepub fn day_number(self) -> i64
pub fn day_number(self) -> i64
Days since 1970-01-01, negative before it.
Sourcepub fn days_since(self, earlier: CalendarDate) -> i64
pub fn days_since(self, earlier: CalendarDate) -> i64
Days from earlier to self, negative when self is the earlier one.
Trait Implementations§
Source§impl Clone for CalendarDate
impl Clone for CalendarDate
Source§fn clone(&self) -> CalendarDate
fn clone(&self) -> CalendarDate
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CalendarDate
Source§impl Debug for CalendarDate
impl Debug for CalendarDate
Source§impl Display for CalendarDate
ISO 8601, because that is what the Python client’s retrieved.isoformat() puts
in the report header and the two have to be diffable.
impl Display for CalendarDate
ISO 8601, because that is what the Python client’s retrieved.isoformat() puts
in the report header and the two have to be diffable.
impl Eq for CalendarDate
Source§impl Hash for CalendarDate
impl Hash for CalendarDate
Source§impl Ord for CalendarDate
impl Ord for CalendarDate
Source§fn cmp(&self, other: &CalendarDate) -> Ordering
fn cmp(&self, other: &CalendarDate) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for CalendarDate
impl PartialEq for CalendarDate
Source§impl PartialOrd for CalendarDate
impl PartialOrd for CalendarDate
impl StructuralPartialEq for CalendarDate
Auto Trait Implementations§
impl Freeze for CalendarDate
impl RefUnwindSafe for CalendarDate
impl Send for CalendarDate
impl Sync for CalendarDate
impl Unpin for CalendarDate
impl UnsafeUnpin for CalendarDate
impl UnwindSafe for CalendarDate
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
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
key and return true if they are equal.