index.js 705 B

1234567891011121314151617181920212223
  1. import toDate from "../toDate/index.js";
  2. import requiredArgs from "../_lib/requiredArgs/index.js";
  3. /**
  4. * @name isFirstDayOfMonth
  5. * @category Month Helpers
  6. * @summary Is the given date the first day of a month?
  7. *
  8. * @description
  9. * Is the given date the first day of a month?
  10. *
  11. * @param {Date|Number} date - the date to check
  12. * @returns {Boolean} the date is the first day of a month
  13. * @throws {TypeError} 1 argument required
  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 default function isFirstDayOfMonth(dirtyDate) {
  21. requiredArgs(1, arguments);
  22. return toDate(dirtyDate).getDate() === 1;
  23. }