123456789101112131415161718192021222324 |
- var parse = require('../parse/index.js')
- /**
- * @category Quarter Helpers
- * @summary Get the year quarter of the given date.
- *
- * @description
- * Get the year quarter of the given date.
- *
- * @param {Date|String|Number} date - the given date
- * @returns {Number} the quarter
- *
- * @example
- * // Which quarter is 2 July 2014?
- * var result = getQuarter(new Date(2014, 6, 2))
- * //=> 3
- */
- function getQuarter (dirtyDate) {
- var date = parse(dirtyDate)
- var quarter = Math.floor(date.getMonth() / 3) + 1
- return quarter
- }
- module.exports = getQuarter
|