This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
admin-panel/graphql-types/node_modules/date-fns/set_day_of_year/index.js

28 lines
757 B
JavaScript

var parse = require('../parse/index.js')
/**
* @category Day Helpers
* @summary Set the day of the year to the given date.
*
* @description
* Set the day of the year to the given date.
*
* @param {Date|String|Number} date - the date to be changed
* @param {Number} dayOfYear - the day of the year of the new date
* @returns {Date} the new date with the day of the year setted
*
* @example
* // Set the 2nd day of the year to 2 July 2014:
* var result = setDayOfYear(new Date(2014, 6, 2), 2)
* //=> Thu Jan 02 2014 00:00:00
*/
function setDayOfYear (dirtyDate, dirtyDayOfYear) {
var date = parse(dirtyDate)
var dayOfYear = Number(dirtyDayOfYear)
date.setMonth(0)
date.setDate(dayOfYear)
return date
}
module.exports = setDayOfYear