Rxova
Skip to content

daysInMonth

function daysInMonth(year, month): number;

Days in a month, given what is known so far.

Both arguments are nullable because the user types in whatever order they like. With no month, 31 is the only safe upper bound — narrowing it early would reject a valid 31 typed before the month. With a February and no year, 29 is the safe answer for the same reason: a leap year is still possible.

ParameterType
yearnumber | null
monthnumber | null

number