isLastDayOfMonth.cjs 840 B

12345678910111213141516171819202122232425262728293031
  1. "use strict";
  2. exports.isLastDayOfMonth = isLastDayOfMonth;
  3. var _index = require("./endOfDay.cjs");
  4. var _index2 = require("./endOfMonth.cjs");
  5. var _index3 = require("./toDate.cjs");
  6. /**
  7. * @name isLastDayOfMonth
  8. * @category Month Helpers
  9. * @summary Is the given date the last day of a month?
  10. *
  11. * @description
  12. * Is the given date the last day of a month?
  13. *
  14. * @param date - The date to check
  15. * @param options - An object with options
  16. *
  17. * @returns The date is the last day of a month
  18. *
  19. * @example
  20. * // Is 28 February 2014 the last day of a month?
  21. * const result = isLastDayOfMonth(new Date(2014, 1, 28))
  22. * //=> true
  23. */
  24. function isLastDayOfMonth(date, options) {
  25. const _date = (0, _index3.toDate)(date, options?.in);
  26. return (
  27. +(0, _index.endOfDay)(_date, options) ===
  28. +(0, _index2.endOfMonth)(_date, options)
  29. );
  30. }