isFirstDayOfMonth.mjs 789 B

123456789101112131415161718192021222324252627
  1. import { toDate } from "./toDate.mjs";
  2. /**
  3. * @name isFirstDayOfMonth
  4. * @category Month Helpers
  5. * @summary Is the given date the first day of a month?
  6. *
  7. * @description
  8. * Is the given date the first day of a month?
  9. *
  10. * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
  11. *
  12. * @param date - The date to check
  13. * @returns The date is the first day of a month
  14. *
  15. * @example
  16. * // Is 1 September 2014 the first day of a month?
  17. * const result = isFirstDayOfMonth(new Date(2014, 8, 1))
  18. * //=> true
  19. */
  20. export function isFirstDayOfMonth(date) {
  21. return toDate(date).getDate() === 1;
  22. }
  23. // Fallback for modularized imports:
  24. export default isFirstDayOfMonth;