Skip to content

Instantly share code, notes, and snippets.

@garenyondem
Created October 18, 2018 13:42
Show Gist options
  • Select an option

  • Save garenyondem/e021f4fb02fc40a2453a9f8b695bc2a3 to your computer and use it in GitHub Desktop.

Select an option

Save garenyondem/e021f4fb02fc40a2453a9f8b695bc2a3 to your computer and use it in GitHub Desktop.
Mother's day & father's day helper
'use strict';
function getMothersDay(year) {
// Earliest possible Mothers day
var date = new Date(year, 4, 7);
date.setDate(7 + (7 - date.getDay()));
return date;
}
function getFathersDay(year) {
// Earliest possible Fathers day
var date = new Date(year, 5, 14);
date.setDate(7 + (14 - date.getDay()));
return date;
}
module.exports = {
getFathersDay: getFathersDay,
getMothersDay: getMothersDay
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment