Temporal.PlainDate.Weekday
- Package
- purescript-temporal
- Repository
- philippedev101/purescript-temporal
Weekday utilities for PlainDate.
Provides a Weekday ADT with full typeclass instances, weekday predicates,
business day arithmetic, and ordinal weekday functions (e.g. "3rd Thursday
of the month").
All functions are pure PureScript — no FFI required.
#getWeekday Source
getWeekday :: PlainDate -> WeekdayGet the weekday of a date.
#addBusinessDays Source
addBusinessDays :: Int -> PlainDate -> PlainDateAdd business days (Monday–Friday), skipping weekends. Supports negative values for going backward.
addBusinessDays 1 friday == monday -- skips weekend
addBusinessDays (-1) monday == friday -- skips weekend backward
addBusinessDays 0 saturday == saturday -- identity
addBusinessDays 6 monday == tuesday -- 5 days = 1 week, +1
#nextWeekday Source
nextWeekday :: Weekday -> PlainDate -> PlainDateThe next occurrence of the given weekday, always advancing at least 1 day.
nextWeekday Monday someMonday == next Monday (7 days later)
nextWeekday Wednesday someMonday == next Wednesday (2 days later)
#nextOrSameWeekday Source
nextOrSameWeekday :: Weekday -> PlainDate -> PlainDateThe next occurrence of the given weekday, or the same date if it already matches.
#previousWeekday Source
previousWeekday :: Weekday -> PlainDate -> PlainDateThe previous occurrence of the given weekday, always retreating at least 1 day.
#previousOrSameWeekday Source
previousOrSameWeekday :: Weekday -> PlainDate -> PlainDateThe previous occurrence of the given weekday, or the same date if it already matches.
#dayOfWeekInSameWeek Source
dayOfWeekInSameWeek :: Weekday -> PlainDate -> PlainDateFind the given weekday within the same ISO week as the input date. The ISO week runs Monday through Sunday.
dayOfWeekInSameWeek Wednesday someMonday == the Wednesday of that week
dayOfWeekInSameWeek Monday someSunday == the Monday of that week
#nthWeekdayOfMonth Source
nthWeekdayOfMonth :: Int -> Weekday -> PlainDate -> Maybe PlainDateThe nth occurrence of a weekday within the month containing the given
date. Returns Nothing if the nth occurrence doesn't exist (e.g. there
is no 5th Monday in most months).
-- Thanksgiving: 4th Thursday of November
nthWeekdayOfMonth 4 Thursday (plainDate 2024 11 1)
-- 1st Monday of the month
nthWeekdayOfMonth 1 Monday (plainDate 2024 3 15)
- Modules
- Temporal.
Diff - Temporal.
Display - Temporal.
Duration - Temporal.
Duration. Extra - Temporal.
Format. Html - Temporal.
Instant - Temporal.
Instant. Extra - Temporal.
Internal. Options - Temporal.
Internal. Types - Temporal.
Internal. Unsafe - Temporal.
Interval - Temporal.
Interval. Duration - Temporal.
Interval. Set - Temporal.
Now - Temporal.
PlainDate - Temporal.
PlainDate. Boundary - Temporal.
PlainDate. Extra - Temporal.
PlainDate. Weekday - Temporal.
PlainDateTime - Temporal.
PlainDateTime. Extra - Temporal.
PlainMonthDay - Temporal.
PlainTime - Temporal.
PlainTime. Extra - Temporal.
PlainYearMonth - Temporal.
PlainYearMonth. Extra - Temporal.
Predicate - Temporal.
TimeDuration - Temporal.
ZonedDateTime - Temporal.
ZonedDateTime. Boundary - Temporal.
ZonedDateTime. Extra