@unikue/ts-lang-utils
    Preparing search index...

    Function addYear

    • Returns the year calculated date with the source date and the specified amount

      If the target year does not have the same day (e.g. Feb 29 in a non-leap year), the result is clamped to the last day of the target month

      Parameters

      • Optionaldate: Date

        The date to inspect

      • Optionalamount: number

        The amount to add, negative number means minus

      Returns Date | undefined

      the year calculated date with the source date and the specified amount

      David Hsing

      addYear(new Date(2023, 8, 30), 1);    // Date(2024, 8, 30)
      addYear(new Date(2024, 1, 29), 1); // Date(2025, 1, 28)