isFirstDayOfMonth.js 731 B

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