Source: isFirstDayOfMonth/index.js

  1. import toDate from '../toDate/index'
  2. import requiredArgs from '../_lib/requiredArgs/index'
  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. * ### v2.0.0 breaking changes:
  12. *
  13. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  14. *
  15. * @param {Date|Number} date - the date to check
  16. * @returns {Boolean} the date is the first day of a month
  17. * @throws {TypeError} 1 argument required
  18. *
  19. * @example
  20. * // Is 1 September 2014 the first day of a month?
  21. * var result = isFirstDayOfMonth(new Date(2014, 8, 1))
  22. * //=> true
  23. */
  24. export default function isFirstDayOfMonth(dirtyDate) {
  25. requiredArgs(1, arguments)
  26. return toDate(dirtyDate).getDate() === 1
  27. }