You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							24 lines
						
					
					
						
							556 B
						
					
					
				
			
		
		
	
	
							24 lines
						
					
					
						
							556 B
						
					
					
				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
 | 
						|
 |