Skip to content

@jsvision/ui / daysInMonth

Function: daysInMonth()

daysInMonth(year, month): number

Defined in: ui/src/date/calendar-date.ts:44

Days in a month, Gregorian leap-year-correct. Returns 0 for a month outside 1-12, so an out-of-range value is rejected rather than yielding NaN.

Parameters

year

number

The full year (e.g. 2026).

month

number

The 1-based month (1-12).

Returns

number

The number of days in the month (28-31), or 0 if month is out of range.

Example

ts
daysInMonth(2024, 2); // 29 (leap year)
daysInMonth(2026, 2); // 28
daysInMonth(2026, 4); // 30