Skip to content

addYears

The addYears() function adds a number of years to a TheDate. It accepts a curried signature to compose transformations.

Interactive example

Syntax

Classic signature

typescript
function addYears<
	GenericInput extends TheDate | SerializedTheDate,
	GenericYear extends number
>(
	input: GenericInput,
	year: GenericYear
): TheDate

Curried signature

typescript
function addYears<
	GenericInput extends TheDate | SerializedTheDate,
	GenericYear extends number
>(
	year: GenericYear
): (input: GenericInput) => TheDate

Parameters

  • year: Number of years.
  • input: TheDate or SerializedTheDate.

Return value

A new TheDate incremented by the requested number of years.

See also

Sources

Released under the MIT license.