isFirstDayOfMonth.js 781 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. exports.isFirstDayOfMonth = isFirstDayOfMonth;
  3. var _index = require("./toDate.js");
  4. /**
  5. * @name isFirstDayOfMonth
  6. * @category Month Helpers
  7. * @summary Is the given date the first day of a month?
  8. *
  9. * @description
  10. * Is the given date the first day of a month?
  11. *
  12. * @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).
  13. *
  14. * @param date - The date to check
  15. * @returns The date is the first day of a month
  16. *
  17. * @example
  18. * // Is 1 September 2014 the first day of a month?
  19. * const result = isFirstDayOfMonth(new Date(2014, 8, 1))
  20. * //=> true
  21. */
  22. function isFirstDayOfMonth(date) {
  23. return (0, _index.toDate)(date).getDate() === 1;
  24. }