Skip to main content

YearMonth

ฦฌ YearMonth: Format["YYYY-MM"] & string

A Iso.YearMonth represents a particular month on the calendar. For example, it could be used to represent a particular instance of a monthly recurring event, like "the June 2019 meeting".

Iso.YearMonth refers to the whole of a specific month; if you need to refer to a calendar event on a certain day, use Iso.Date or even Iso.DateTime. A Iso.YearMonth can be converted into a Iso.Date by combining it with a day of the month, using the toDate() function.

Defined in

iso-types.ts:104

fromNumbers

โ–ธ fromNumbers(year, month): YearMonth

Parameters

NameType
yearnumber
monthnumber

Returns

YearMonth

Defined in

types/IYearMonthFns.ts:7


isValid

โ–ธ isValid(yearMonth): yearMonth is YearMonth

Parameters

NameType
yearMonthunknown

Returns

yearMonth is YearMonth

Defined in

types/IYearMonthFns.ts:8


assertIsValid

โ–ธ assertIsValid(yearMonth): asserts yearMonth is YearMonth

Parameters

NameType
yearMonthunknown

Returns

asserts yearMonth is YearMonth

Defined in

types/IYearMonthFns.ts:9


getYear

โ–ธ getYear(yearMonth): number

Parameters

NameType
yearMonthYearMonth

Returns

number

Defined in

types/IYearMonthFns.ts:10


getMonth

โ–ธ getMonth(yearMonth): number

Parameters

NameType
yearMonthYearMonth

Returns

number

Defined in

types/IYearMonthFns.ts:11


getDaysInMonth

โ–ธ getDaysInMonth(yearMonth): number

Parameters

NameType
yearMonthYearMonth

Returns

number

Defined in

types/IYearMonthFns.ts:12


getDaysInYear

โ–ธ getDaysInYear(yearMonth): number

Parameters

NameType
yearMonthYearMonth

Returns

number

Defined in

types/IYearMonthFns.ts:13


inLeapYear

โ–ธ inLeapYear(yearMonth): boolean

Parameters

NameType
yearMonthYearMonth

Returns

boolean

Defined in

types/IYearMonthFns.ts:14


with

โ–ธ with(yearMonth, yearMonthLike, options?): YearMonth

Parameters

NameType
yearMonthYearMonth
yearMonthLikeObject
yearMonthLike.year?number
yearMonthLike.month?number
options?Object
options.overflowTemporalOverflow

Returns

YearMonth

Defined in

types/IYearMonthFns.ts:15


add

โ–ธ add(yearMonth, temporalDurationLike, options?): YearMonth

Parameters

NameType
yearMonthYearMonth
temporalDurationLikeDuration | { years?: number ; months?: number ; weeks?: number ; days?: number ; hours?: number ; minutes?: number ; seconds?: number ; milliseconds?: number }
options?Object
options.overflow?TemporalOverflow

Returns

YearMonth

Defined in

types/IYearMonthFns.ts:20


subtract

โ–ธ subtract(yearMonth, temporalDurationLike, options?): YearMonth

Parameters

NameType
yearMonthYearMonth
temporalDurationLikeDuration | { years?: number ; months?: number ; weeks?: number ; days?: number ; hours?: number ; minutes?: number ; seconds?: number ; milliseconds?: number }
options?Object
options.overflow?TemporalOverflow

Returns

YearMonth

Defined in

types/IYearMonthFns.ts:36


until

โ–ธ until(yearMonth, other, options?): Duration

Parameters

NameType
yearMonthYearMonth
otherYearMonth
options?Object
options.largestUnit?TemporalSingularUnit | TemporalPluralUnit | "auto"
options.smallestUnit?TemporalSingularUnit | TemporalPluralUnit
options.roundingIncrement?number
options.roundingMode?TemporalRoundingMode

Returns

Duration

Defined in

types/IYearMonthFns.ts:52


since

โ–ธ since(yearMonth, other, options?): Duration

Parameters

NameType
yearMonthYearMonth
otherYearMonth
options?Object
options.largestUnit?TemporalSingularUnit | TemporalPluralUnit | "auto"
options.smallestUnit?TemporalSingularUnit | TemporalPluralUnit
options.roundingIncrement?number
options.roundingMode?TemporalRoundingMode

Returns

Duration

Defined in

types/IYearMonthFns.ts:62


equals

โ–ธ equals(yearMonth, other): boolean

Parameters

NameType
yearMonthYearMonth
otherYearMonth

Returns

boolean

Defined in

types/IYearMonthFns.ts:72


isEqual

โ–ธ isEqual(yearMonth, other): boolean

alias for equals

Parameters

NameType
yearMonthYearMonth
otherYearMonth

Returns

boolean

Defined in

types/IYearMonthFns.ts:76


isBefore

โ–ธ isBefore(yearMonth, other): boolean

Parameters

NameType
yearMonthYearMonth
otherYearMonth

Returns

boolean

Defined in

types/IYearMonthFns.ts:77


isAfter

โ–ธ isAfter(yearMonth, other): boolean

Parameters

NameType
yearMonthYearMonth
otherYearMonth

Returns

boolean

Defined in

types/IYearMonthFns.ts:78


isEqualOrBefore

โ–ธ isEqualOrBefore(yearMonth, other): boolean

Parameters

NameType
yearMonthYearMonth
otherYearMonth

Returns

boolean

Defined in

types/IYearMonthFns.ts:79


isEqualOrAfter

โ–ธ isEqualOrAfter(yearMonth, other): boolean

Parameters

NameType
yearMonthYearMonth
otherYearMonth

Returns

boolean

Defined in

types/IYearMonthFns.ts:80


toDate

โ–ธ toDate(yearMonth, day): Date

Parameters

NameType
yearMonthYearMonth
daynumber

Returns

Date

Defined in

types/IYearMonthFns.ts:81


getFields

โ–ธ getFields(yearMonth): YearMonthSlots

Parameters

NameType
yearMonthYearMonth

Returns

YearMonthSlots

Defined in

types/IYearMonthFns.ts:82


from

โ–ธ from(item, options?): YearMonth

Parameters

NameType
itemany
options?Object
options.overflowTemporalOverflow

Returns

YearMonth

Defined in

types/IYearMonthFns.ts:83


compare

โ–ธ compare(one, two): number

Parameters

NameType
oneYearMonth
twoYearMonth

Returns

number

Defined in

types/IYearMonthFns.ts:84


format

โ–ธ format(yearMonth, format): string

summary Format the ZonedDateTime.

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
EraG..GGGAD, BC
GGGGAnno Domini, Before Christ1
GGGGGA, B
Calendar yeary44, 1, 1900, 20174
yo44th, 1st, 0th, 17th4,5
yy44, 01, 00, 174
yyy044, 001, 1900, 20174
yyyy0044, 0001, 1900, 20174
yyyyy...2,4
Extended yearu-43, 0, 1, 1900, 20174
uu-43, 01, 1900, 20174
uuu-043, 001, 1900, 20174
uuuu-0043, 0001, 1900, 20174
uuuuu...2,4
QuarterQ1, 2, 3, 4
Qo1st, 2nd, 3rd, 4th5
QQ01, 02, 03, 04
QQQQ1, Q2, Q3, Q4
QQQQ1st quarter, 2nd quarter, ...1
QQQQQ1, 2, 3, 43
MonthM1, 2, ..., 12
Mo1st, 2nd, ..., 12th5
MM01, 02, ..., 12
MMMJan, Feb, ..., Dec
MMMMJanuary, February, ..., December1
MMMMMJ, F, ..., D

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. Some patterns could be unlimited length (such as yyyyyyyy). The output will be padded with zeros to match the length of the pattern.

    format("2017-11-06", 'yyyyyyyy') //=> '00002017'

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

  4. The main difference between y and u patterns are B.C. years:

    Yearyu
    AC 111
    BC 110
    BC 22-1

    Also yy always returns the last two digits of a year, while uu pads single digit years to 2 characters and returns other years unchanged:

    Yearyyuu
    10101
    141414
    37676376
    1453531453
  5. 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("2014-02", 'MM/yyyy')
//=> '02/2014'

Parameters

NameTypeDescription
yearMonthYearMonththe original date
formatstringthe string of tokens

Returns

string

the formatted date string

Defined in

types/IYearMonthFns.ts:189


chain

โ–ธ chain(yearMonth): IYearMonthChain

Parameters

NameType
yearMonthYearMonth

Returns

IYearMonthChain

Defined in

types/IYearMonthFns.ts:190