getMonth.js 627 B

123456789101112131415161718192021222324252627282930
  1. import { toDate } from "./toDate.js";
  2. /**
  3. * The {@link getMonth} function options.
  4. */
  5. /**
  6. * @name getMonth
  7. * @category Month Helpers
  8. * @summary Get the month of the given date.
  9. *
  10. * @description
  11. * Get the month of the given date.
  12. *
  13. * @param date - The given date
  14. * @param options - An object with options
  15. *
  16. * @returns The month index (0-11)
  17. *
  18. * @example
  19. * // Which month is 29 February 2012?
  20. * const result = getMonth(new Date(2012, 1, 29))
  21. * //=> 1
  22. */
  23. export function getMonth(date, options) {
  24. return toDate(date, options?.in).getMonth();
  25. }
  26. // Fallback for modularized imports:
  27. export default getMonth;