Skip to main content

A Iso.MonthDay represents a particular day on the calendar, but without a year. For example, it could be used to represent a yearly recurring event, like "Bastille Day is on the 14th of July."

If you need to refer to a certain instance of a calendar event, in a particular year, use Iso.Date or even Iso.DateTime. A Iso.MonthDay can be converted into a Iso.Date by combining it with a year, using the toDate() method.

fromNumbers()​

fromNumbers(month, day): MonthDay

Parameters​

month​

number

day​

number

Returns​

MonthDay


isValid()​

isValid(monthDay): monthDay is MonthDay

Parameters​

monthDay​

unknown

Returns​

monthDay is MonthDay


assertIsValid()​

assertIsValid(monthDay): asserts monthDay is MonthDay

Parameters​

monthDay​

unknown

Returns​

asserts monthDay is MonthDay


getDay()​

getDay(monthDay): number

Parameters​

monthDay​

MonthDay

Returns​

number


getMonth()​

getMonth(monthDay): number

Parameters​

monthDay​

MonthDay

Returns​

number


with()​

with(monthDay, monthDayLike, options?): MonthDay

Parameters​

monthDay​

MonthDay

monthDayLike​

month​

number

day​

number

options?​

overflow​

"constrain" | "reject"

Returns​

MonthDay


equals()​

equals(monthDay, other): boolean

Parameters​

monthDay​

MonthDay

other​

MonthDay

Returns​

boolean


isEqual()​

isEqual(monthDay, other): boolean

Parameters​

monthDay​

MonthDay

other​

MonthDay

Returns​

boolean


toDate()​

toDate(monthDay, year): Date

Parameters​

monthDay​

MonthDay

year​

number

Returns​

Date


getFields()​

getFields(monthDay): object

Parameters​

monthDay​

MonthDay

Returns​

object

month​

month: number

day​

day: number


from()​

from(item, options?): MonthDay

Parameters​

item​

string | Partial\<{ month: number; day: number; year: number; }>

options?​

overflow​

"constrain" | "reject"

Returns​

MonthDay


compare()​

compare(one, two): number

Parameters​

one​

MonthDay

two​

MonthDay

Returns​

number


format()​

format(monthDay, format, options?): string

Parameters​

monthDay​

MonthDay

the original date

format​

string

the string of tokens

options?​

FormatOptions

Returns​

string

the formatted date string

Description​

Return the formatted ZonedDateTime string in the given format.

The characters wrapped between two single quotes characters (') are escaped. Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote. (see the last example)

Format of the string is based on Unicode Technical Standard #35: https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table with a few additions (see note 7 below the table).

Accepted patterns:

UnitPatternResult examplesNotes
QuarterQ1, 2, 3, 4
Qo1st, 2nd, 3rd, 4th3
QQ01, 02, 03, 04
QQQQ1, Q2, Q3, Q4
QQQQ1st quarter, 2nd quarter, ...1
QQQQQ1, 2, 3, 42
MonthM1, 2, ..., 12
Mo1st, 2nd, ..., 12th3
MM01, 02, ..., 12
MMMJan, Feb, ..., Dec
MMMMJanuary, February, ..., December1
MMMMMJ, F, ..., D
Day of monthd1, 2, ..., 31
do1st, 2nd, ..., 31st3
dd01, 02, ..., 31

Notes:

  1. Any sequence of the identical letters is a pattern, unless it is escaped by the single quote characters (see below). If the sequence is longer than listed in table (e.g. EEEEEEEEEEE) the output will be the same as default pattern for this unit, usually the longest one (in case of ISO weekdays, EEEE). Default patterns for units are marked with "2" in the last column of the table.

    format("2017-11-06", 'MMM') //=> 'Nov'

    format("2017-11-06", 'MMMM') //=> 'November'

    format("2017-11-06", 'MMMMM') //=> 'N'

    format("2017-11-06", 'MMMMMM') //=> 'November'

    format("2017-11-06", 'MMMMMMM') //=> 'November'

  2. QQQQQ could be not strictly numerical in some locales. These tokens represent the shortest form of the quarter.

  3. These patterns are not in the Unicode Technical Standard #35:

    • o: ordinal number modifier
  • Characters are escaped using single quote symbols (').

Example​

// Represent 11 February 2014 in middle-endian format:
var result = format("--02-11", 'MM/dd')
//=> '02/11'

chain()​

chain(monthDay): IMonthDayChain

Parameters​

monthDay​

MonthDay

Returns​

IMonthDayChain