getMonth.cjs 612 B

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