JS.Temporal.PlainMonthDay
- Package
- purescript-js-temporal
- Repository
- pete-murphy/purescript-js-temporal
A month and day without year or time zone. Use for recurring dates (e.g. birthdays, annual events). Requires a year for conversion to PlainDate.
#fromWithOptions Source
fromWithOptions :: forall optsProvided provided rest. Union provided rest PlainMonthDayComponents => ConvertOptionsWithDefaults ToOverflowOptions (Record OverflowOptions) (Record optsProvided) (Record OverflowOptions) => Record optsProvided -> Record provided -> Effect PlainMonthDayCreates a PlainMonthDay from component fields. Options: overflow.
exampleFromWithOptions :: Effect Unit
exampleFromWithOptions = do
holiday <- PlainMonthDay.fromWithOptions { overflow: Overflow.Constrain } { month: 7, day: 4 }
Console.log (PlainMonthDay.toString holiday)
07-04
#from Source
from :: forall provided rest. Union provided rest PlainMonthDayComponents => Record provided -> Effect PlainMonthDaySame as fromWithOptions with default options.
exampleFrom :: Effect Unit
exampleFrom = do
locale <- JS.Intl.Locale.new_ "en-US"
holiday <- PlainMonthDay.from { month: 7, day: 4 }
holidayIn2024 <- PlainMonthDay.toPlainDate { year: 2024 } holiday
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long" }
Console.log (JS.Intl.DateTimeFormat.format formatter holidayIn2024)
July 4, 2024
#fromStringWithOptions Source
fromStringWithOptions :: forall provided. ConvertOptionsWithDefaults ToOverflowOptions (Record OverflowOptions) (Record provided) (Record OverflowOptions) => Record provided -> String -> Effect PlainMonthDayCreates a PlainMonthDay from an RFC 9557 / ISO 8601 month-day string
(e.g. "12-15" or "--01-15"). Options: overflow.
exampleFromStringWithOptions :: Effect Unit
exampleFromStringWithOptions = do
birthday <- PlainMonthDay.fromStringWithOptions { overflow: Overflow.Constrain } "12-15"
Console.log (PlainMonthDay.toString birthday)
12-15
#fromString Source
fromString :: String -> Effect PlainMonthDaySame as fromStringWithOptions with default options.
exampleFromString :: Effect Unit
exampleFromString = do
birthday <- PlainMonthDay.fromString "12-15"
Console.log (PlainMonthDay.toString birthday)
12-15
#monthCode Source
monthCode :: PlainMonthDay -> StringCalendar-specific month code, such as M12.
exampleMonthCode :: Effect Unit
exampleMonthCode = do
mday <- PlainMonthDay.fromString "03-14"
Console.log ("Month code: " <> PlainMonthDay.monthCode mday)
Month code: M03
#day Source
day :: PlainMonthDay -> IntDay of the month.
exampleDay :: Effect Unit
exampleDay = do
mday <- PlainMonthDay.fromString "03-14"
Console.log ("Day: " <> show (PlainMonthDay.day mday))
Day: 14
#calendarId Source
calendarId :: PlainMonthDay -> StringCalendar identifier, such as "iso8601".
exampleCalendarId :: Effect Unit
exampleCalendarId = do
mday <- PlainMonthDay.fromString "03-14"
Console.log ("Calendar: " <> PlainMonthDay.calendarId mday)
Calendar: iso8601
#withWithOptions Source
withWithOptions :: forall optsProvided fields rest. Union fields rest WithFields => ConvertOptionsWithDefaults ToOverflowOptions (Record OverflowOptions) (Record optsProvided) (Record OverflowOptions) => Record optsProvided -> Record fields -> PlainMonthDay -> Effect PlainMonthDayReturns a new PlainMonthDay with specified fields replaced. Options: overflow.
exampleWithWithOptions :: Effect Unit
exampleWithWithOptions = do
original <- PlainMonthDay.fromString "01-15"
changed <- PlainMonthDay.withWithOptions { overflow: Overflow.Constrain } { day: 31 } original
Console.log (PlainMonthDay.toString changed)
01-31
#with Source
with :: forall fields rest. Union fields rest WithFields => Record fields -> PlainMonthDay -> Effect PlainMonthDaySame as withWithOptions with default options.
exampleWith :: Effect Unit
exampleWith = do
original <- PlainMonthDay.fromString "01-15"
changed <- PlainMonthDay.with { day: 28 } original
Console.log (PlainMonthDay.toString changed)
01-28
#toPlainDate Source
toPlainDate :: { year :: Int } -> PlainMonthDay -> Effect PlainDateConverts to PlainDate by supplying a year.
exampleToPlainDate :: Effect Unit
exampleToPlainDate = do
locale <- JS.Intl.Locale.new_ "en-US"
birthday <- PlainMonthDay.fromString "12-15"
birthdayIn2030 <- PlainMonthDay.toPlainDate { year: 2030 } birthday
formatter <- JS.Intl.DateTimeFormat.new [ locale ] { dateStyle: "long" }
Console.log ("Birthday in 2030: " <> JS.Intl.DateTimeFormat.format formatter birthdayIn2030)
Birthday in 2030: December 15, 2030
#toStringWithOptions Source
toStringWithOptions :: forall provided. ConvertOptionsWithDefaults ToToStringOptions (Record ToStringOptions) (Record provided) (Record ToStringOptions) => Record provided -> PlainMonthDay -> StringSerializes to ISO 8601 month-day format. Options: calendarName.
exampleToStringWithOptions :: Effect Unit
exampleToStringWithOptions = do
mday <- PlainMonthDay.fromString "03-14"
Console.log (PlainMonthDay.toStringWithOptions {} mday)
03-14
#toString Source
toString :: PlainMonthDay -> StringSame as toStringWithOptions with default options.
exampleToString :: Effect Unit
exampleToString = do
mday <- PlainMonthDay.fromString "03-14"
Console.log (PlainMonthDay.toString mday)
03-14
#ToOverflowOptions Source
data ToOverflowOptionsInstances
ConvertOption ToOverflowOptions "overflow" Overflow StringConvertOption ToOverflowOptions "overflow" String String
#ToToStringOptions Source
data ToToStringOptionsInstances
ConvertOption ToToStringOptions "calendarName" CalendarName StringConvertOption ToToStringOptions "calendarName" String String
Re-exports from JS.Temporal.PlainMonthDay.Internal
- Modules
- JS.
Temporal. Duration - JS.
Temporal. Duration. Internal - JS.
Temporal. Instant - JS.
Temporal. Instant. Internal - JS.
Temporal. Internal - JS.
Temporal. Now - JS.
Temporal. Options. CalendarName - JS.
Temporal. Options. Disambiguation - JS.
Temporal. Options. OffsetDisambiguation - JS.
Temporal. Options. Overflow - JS.
Temporal. Options. RoundingMode - JS.
Temporal. Options. TemporalUnit - JS.
Temporal. PlainDate - JS.
Temporal. PlainDate. Internal - JS.
Temporal. PlainDateTime - JS.
Temporal. PlainDateTime. Internal - JS.
Temporal. PlainMonthDay - JS.
Temporal. PlainMonthDay. Internal - JS.
Temporal. PlainTime - JS.
Temporal. PlainTime. Internal - JS.
Temporal. PlainYearMonth - JS.
Temporal. PlainYearMonth. Internal - JS.
Temporal. ZonedDateTime - JS.
Temporal. ZonedDateTime. Internal