index.js 723 B

12345678910111213141516171819202122232425
  1. var parse = require('../parse/index.js')
  2. var endOfDay = require('../end_of_day/index.js')
  3. var endOfMonth = require('../end_of_month/index.js')
  4. /**
  5. * @category Month Helpers
  6. * @summary Is the given date the last day of a month?
  7. *
  8. * @description
  9. * Is the given date the last day of a month?
  10. *
  11. * @param {Date|String|Number} date - the date to check
  12. * @returns {Boolean} the date is the last day of a month
  13. *
  14. * @example
  15. * // Is 28 February 2014 the last day of a month?
  16. * var result = isLastDayOfMonth(new Date(2014, 1, 28))
  17. * //=> true
  18. */
  19. function isLastDayOfMonth (dirtyDate) {
  20. var date = parse(dirtyDate)
  21. return endOfDay(date).getTime() === endOfMonth(date).getTime()
  22. }
  23. module.exports = isLastDayOfMonth