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
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
Returns
number
getMonth()
getMonth(
monthDay):number
Parameters
monthDay
Returns
number
with()
with(
monthDay,monthDayLike,options?):MonthDay
Parameters
monthDay
monthDayLike
month
number
day
number
options?
overflow
"constrain" | "reject"
Returns
equals()
equals(
monthDay,other):boolean
Parameters
monthDay
other
Returns
boolean
isEqual()
isEqual(
monthDay,other):boolean
Parameters
monthDay
other
Returns
boolean
toDate()
toDate(
monthDay,year):Date
Parameters
monthDay
year
number
Returns
getFields()
getFields(
monthDay):object
Parameters
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
compare()
compare(
one,two):number
Parameters
one
two
Returns
number
format()
format(
monthDay,format,options?):string
Parameters
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:
| Unit | Pattern | Result examples | Notes |
|---|---|---|---|
| Quarter | Q | 1, 2, 3, 4 | |
| Qo | 1st, 2nd, 3rd, 4th | 3 | |
| 01, 02, 03, 04 | |||
| QQQ | Q1, Q2, Q3, Q4 | ||
| QQQQ | 1st quarter, 2nd quarter, ... | 1 | |
| QQQQQ | 1, 2, 3, 4 | 2 | |
| Month | M | 1, 2, ..., 12 | |
| Mo | 1st, 2nd, ..., 12th | 3 | |
| MM | 01, 02, ..., 12 | ||
| MMM | Jan, Feb, ..., Dec | ||
| MMMM | January, February, ..., December | 1 | |
| MMMMM | J, F, ..., D | ||
| Day of month | d | 1, 2, ..., 31 | |
| do | 1st, 2nd, ..., 31st | 3 | |
| dd | 01, 02, ..., 31 |
Notes:
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'QQQQQcould be not strictly numerical in some locales. These tokens represent the shortest form of the quarter.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
Returns
IMonthDayChain