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.
		
		
		
		
		
			
		
			
				
					
					
						
							32 lines
						
					
					
						
							1.0 KiB
						
					
					
				
			
		
		
	
	
							32 lines
						
					
					
						
							1.0 KiB
						
					
					
				var getISOYear = require('../get_iso_year/index.js') | 
						|
var startOfISOWeek = require('../start_of_iso_week/index.js') | 
						|
 | 
						|
/** | 
						|
 * @category ISO Week-Numbering Year Helpers | 
						|
 * @summary Return the start of an ISO week-numbering year for the given date. | 
						|
 * | 
						|
 * @description | 
						|
 * Return the start of an ISO week-numbering year, | 
						|
 * which always starts 3 days before the year's first Thursday. | 
						|
 * The result will be in the local timezone. | 
						|
 * | 
						|
 * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date | 
						|
 * | 
						|
 * @param {Date|String|Number} date - the original date | 
						|
 * @returns {Date} the start of an ISO year | 
						|
 * | 
						|
 * @example | 
						|
 * // The start of an ISO week-numbering year for 2 July 2005: | 
						|
 * var result = startOfISOYear(new Date(2005, 6, 2)) | 
						|
 * //=> Mon Jan 03 2005 00:00:00 | 
						|
 */ | 
						|
function startOfISOYear (dirtyDate) { | 
						|
  var year = getISOYear(dirtyDate) | 
						|
  var fourthOfJanuary = new Date(0) | 
						|
  fourthOfJanuary.setFullYear(year, 0, 4) | 
						|
  fourthOfJanuary.setHours(0, 0, 0, 0) | 
						|
  var date = startOfISOWeek(fourthOfJanuary) | 
						|
  return date | 
						|
} | 
						|
 | 
						|
module.exports = startOfISOYear
 | 
						|
 |