PlainDate
represents a date in the Year-Month-Day (YMD) format. It encapsulates the year, month,
and day components, with validation to ensure the date is valid.
- year : Std.Time.Year.Offset
The year component of the date. It is represented as an
Offset
type fromYear
. - month : Std.Time.Month.Ordinal
The month component of the date. It is represented as an
Ordinal
type fromMonth
. - day : Std.Time.Day.Ordinal
The day component of the date. It is represented as an
Ordinal
type fromDay
. - valid : self.year.Valid self.month self.day
Validates the date by ensuring that the year, month, and day form a correct and valid date.
Instances For
Equations
- Std.Time.instInhabitedPlainDate = { default := { year := 1, month := 1, day := 1, valid := Std.Time.instInhabitedPlainDate.proof_1 } }
Creates a PlainDate
by clipping the day to ensure validity. This function forces the date to be
valid by adjusting the day to fit within the valid range to fit the given month and year.
Instances For
Creates a new PlainDate
from year, month, and day components.
Equations
- Std.Time.PlainDate.ofYearMonthDay? year month day = if valid : year.Valid month day then some { year := year, month := month, day := day, valid := valid } else none
Instances For
Creates a PlainDate
from a year and a day ordinal within that year.
Equations
- Std.Time.PlainDate.ofYearOrdinal year ordinal = match Std.Time.ValidDate.ofOrdinal ordinal with | ⟨(month, day), proof⟩ => { year := year, month := month, day := day, valid := proof }
Instances For
Creates a PlainDate
from the number of days since the UNIX epoch (January 1st, 1970).
Equations
- One or more equations did not get rendered due to their size.
Instances For
Returns the unaligned week of the month for a PlainDate
(day divided by 7, plus 1).
Equations
- date.weekOfMonth = ((Std.Time.Internal.Bounded.LE.sub date.day 1).ediv 7 Std.Time.PlainDate.weekOfMonth.proof_1).add 1
Instances For
Determines the quarter of the year for the given PlainDate
.
Instances For
Transforms a PlainDate
into a Day.Ordinal.OfYear
.
Equations
- date.dayOfYear = Std.Time.ValidDate.dayOfYear ⟨(date.month, date.day), ⋯⟩
Instances For
Converts a PlainDate
to the number of days since the UNIX epoch.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Adds a given number of days to a PlainDate
.
Instances For
Subtracts a given number of days from a PlainDate
.
Instances For
Adds a given number of weeks to a PlainDate
.
Equations
- date.addWeeks weeks = Std.Time.PlainDate.ofDaysSinceUNIXEpoch (date.toDaysSinceUNIXEpoch + weeks.toDays)
Instances For
Subtracts a given number of weeks from a PlainDate
.
Instances For
Adds a given number of months to a PlainDate
, clipping the day to the last valid day of the month.
Instances For
Subtracts Month.Offset
from a PlainDate
, it clips the day to the last valid day of that month.
Instances For
Creates a PlainDate
by rolling over the extra days to the next month.
Instances For
Creates a new PlainDate
by adjusting the year to the given year
value. The month and day remain unchanged,
and any invalid days for the new year will be handled according to the clip
behavior.
Instances For
Creates a new PlainDate
by adjusting the year to the given year
value. The month and day are rolled
over to the next valid month and day if necessary.
Equations
- dt.withYearRollOver year = Std.Time.PlainDate.rollOver year dt.month dt.day
Instances For
Adds a given number of months to a PlainDate
, rolling over any excess days into the following month.
Equations
- date.addMonthsRollOver months = ((Std.Time.PlainDate.ofYearMonthDayClip date.year date.month 1).addMonthsClip months).addDays (date.day.toOffset - 1)
Instances For
Subtracts Month.Offset
from a PlainDate
, rolling over excess days as needed.
Instances For
Adds Year.Offset
to a PlainDate
, rolling over excess days to the next month, or next year.
Instances For
Subtracts Year.Offset
from a PlainDate
, rolling over excess days to the next month.
Instances For
Adds Year.Offset
to a PlainDate
, clipping the day to the last valid day of the month.
Instances For
Subtracts Year.Offset
from a PlainDate
, clipping the day to the last valid day of the month.
Instances For
Creates a new PlainDate
by adjusting the day of the month to the given days
value, with any
out-of-range days clipped to the nearest valid date.
Instances For
Creates a new PlainDate
by adjusting the day of the month to the given days
value, with any
out-of-range days rolled over to the next month or year as needed.
Equations
- dt.withDaysRollOver days = Std.Time.PlainDate.rollOver dt.year dt.month days
Instances For
Creates a new PlainDate
by adjusting the month to the given month
value.
The day remains unchanged, and any invalid days for the new month will be handled according to the clip
behavior.
Equations
- dt.withMonthClip month = Std.Time.PlainDate.ofYearMonthDayClip dt.year month dt.day
Instances For
Creates a new PlainDate
by adjusting the month to the given month
value.
The day is rolled over to the next valid month if necessary.
Equations
- dt.withMonthRollOver month = Std.Time.PlainDate.rollOver dt.year month dt.day
Instances For
Calculates the Weekday
of a given PlainDate
using Zeller's Congruence for the Gregorian calendar.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Determines the week of the month for the given PlainDate
. The week of the month is calculated based
on the day of the month and the weekday. Each week starts on Monday because the entire library is
based on the Gregorian Calendar.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Sets the date to the specified desiredWeekday
. If the desiredWeekday
is the same as the current weekday,
the original date
is returned without modification. If the desiredWeekday
is in the future, the
function adjusts the date forward to the next occurrence of that weekday.
Instances For
Calculates the week of the year starting Monday for a given year.