index.js 847 B

1234567891011121314151617181920212223242526
  1. import toDate from "../toDate/index.js";
  2. import endOfDay from "../endOfDay/index.js";
  3. import endOfMonth from "../endOfMonth/index.js";
  4. import requiredArgs from "../_lib/requiredArgs/index.js";
  5. /**
  6. * @name isLastDayOfMonth
  7. * @category Month Helpers
  8. * @summary Is the given date the last day of a month?
  9. *
  10. * @description
  11. * Is the given date the last day of a month?
  12. *
  13. * @param {Date|Number} date - the date to check
  14. * @returns {Boolean} the date is the last day of a month
  15. * @throws {TypeError} 1 argument required
  16. *
  17. * @example
  18. * // Is 28 February 2014 the last day of a month?
  19. * const result = isLastDayOfMonth(new Date(2014, 1, 28))
  20. * //=> true
  21. */
  22. export default function isLastDayOfMonth(dirtyDate) {
  23. requiredArgs(1, arguments);
  24. var date = toDate(dirtyDate);
  25. return endOfDay(date).getTime() === endOfMonth(date).getTime();
  26. }