isLastDayOfMonth.js 922 B

1234567891011121314151617181920212223242526272829
  1. "use strict";
  2. exports.isLastDayOfMonth = isLastDayOfMonth;
  3. var _index = require("./endOfDay.js");
  4. var _index2 = require("./endOfMonth.js");
  5. var _index3 = require("./toDate.js");
  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. * @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).
  15. *
  16. * @param date - The date to check
  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) {
  25. const _date = (0, _index3.toDate)(date);
  26. return +(0, _index.endOfDay)(_date) === +(0, _index2.endOfMonth)(_date);
  27. }