Skip to content

Commit

Permalink
Remove observedName parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
koterpillar committed Jan 10, 2023
1 parent 5a6cf98 commit 4c3a256
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions js/holidays.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,16 @@ function getMonthDays( year ) {
* @param {string} country Country code
* @param {string} name Holiday name
* @param {Object} options Additional options
* @param {string} options.observedName Holiday name for the observed date
* @param {number} options.consecutive How many consecutive holidays is this one a part of (to avoid shifting observed date onto them)
* @returns {string} holiday date in 'month-day' format
*/
function observed( year, month, day, country, name, options ) {
options = options || {};

var diffs = [0],
let diffs = [0],
date = new Date( year, month - 1, day ),
dow = date.getDay();
dow = date.getDay(),
observedName = name;

switch ( country ) {
case 'mx' :
Expand All @@ -391,6 +391,7 @@ function observed( year, month, day, country, name, options ) {
diffs.push( consecutive );
else if ( dow == 6 )
diffs.push( 2 );
observedName = `${name} (in lieu)`;
break;

case 'ar' :
Expand All @@ -406,23 +407,11 @@ function observed( year, month, day, country, name, options ) {
break;
}

var observedName = options.observedName;
if ( !observedName ) {
switch ( country ) {
case 'au':
observedName = `Additional public holiday for ${name}`;
break;
case 'uk':
observedName = `${name} (in lieu)`;
break;
}
}

return diffs.map(diff => {
var newDate = dateToMonthDay( dateAdd( date, diff ) );
return {
date: newDate,
name: ( diff == 0 || !observedName ) ? name : observedName
name: diff == 0 ? name : observedName
}
});
}
Expand Down

0 comments on commit 4c3a256

Please sign in to comment.