index.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = isLastDayOfMonth;
  6. var _index = _interopRequireDefault(require("../toDate/index.js"));
  7. var _index2 = _interopRequireDefault(require("../endOfDay/index.js"));
  8. var _index3 = _interopRequireDefault(require("../endOfMonth/index.js"));
  9. var _index4 = _interopRequireDefault(require("../_lib/requiredArgs/index.js"));
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. /**
  12. * @name isLastDayOfMonth
  13. * @category Month Helpers
  14. * @summary Is the given date the last day of a month?
  15. *
  16. * @description
  17. * Is the given date the last day of a month?
  18. *
  19. * ### v2.0.0 breaking changes:
  20. *
  21. * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).
  22. *
  23. * @param {Date|Number} date - the date to check
  24. * @returns {Boolean} the date is the last day of a month
  25. * @throws {TypeError} 1 argument required
  26. *
  27. * @example
  28. * // Is 28 February 2014 the last day of a month?
  29. * var result = isLastDayOfMonth(new Date(2014, 1, 28))
  30. * //=> true
  31. */
  32. function isLastDayOfMonth(dirtyDate) {
  33. (0, _index4.default)(1, arguments);
  34. var date = (0, _index.default)(dirtyDate);
  35. return (0, _index2.default)(date).getTime() === (0, _index3.default)(date).getTime();
  36. }
  37. module.exports = exports.default;