getYear.cjs 588 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. exports.getYear = getYear;
  3. var _index = require("./toDate.cjs");
  4. /**
  5. * The {@link getYear} function options.
  6. */
  7. /**
  8. * @name getYear
  9. * @category Year Helpers
  10. * @summary Get the year of the given date.
  11. *
  12. * @description
  13. * Get the year of the given date.
  14. *
  15. * @param date - The given date
  16. * @param options - An object with options
  17. *
  18. * @returns The year
  19. *
  20. * @example
  21. * // Which year is 2 July 2014?
  22. * const result = getYear(new Date(2014, 6, 2))
  23. * //=> 2014
  24. */
  25. function getYear(date, options) {
  26. return (0, _index.toDate)(date, options?.in).getFullYear();
  27. }