index.js 558 B

12345678910111213141516171819202122
  1. var isLeapYear = require('../is_leap_year/index.js')
  2. /**
  3. * @category Year Helpers
  4. * @summary Get the number of days in a year of the given date.
  5. *
  6. * @description
  7. * Get the number of days in a year of the given date.
  8. *
  9. * @param {Date|String|Number} date - the given date
  10. * @returns {Number} the number of days in a year
  11. *
  12. * @example
  13. * // How many days are in 2012?
  14. * var result = getDaysInYear(new Date(2012, 0, 1))
  15. * //=> 366
  16. */
  17. function getDaysInYear (dirtyDate) {
  18. return isLeapYear(dirtyDate) ? 366 : 365
  19. }
  20. module.exports = getDaysInYear