Skip to content

Commit

Permalink
[5.3] MSPB-360: Set 'start_date' and 'cycle=date' for non recurring h…
Browse files Browse the repository at this point in the history
…olidays (#525)

* MSPB-360: Set 'start_date' and 'cycle=date' for non recurring holidays

* end_date should use the user/account timezone
  • Loading branch information
pcandia committed Mar 8, 2024
1 parent 7d8ed8b commit 4213582
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions submodules/strategyHolidays/strategyHolidays.js
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,20 @@ define(function(require) {
return ordinalId === 5 ? _.last(datesArray) : datesArray[ordinalId];
},

/**
* Returns Date
* @param {string} selectedYear
* @param {Object} holiday
* @return {Date}
*/
strategyHolidaysGetStartDate: function(selectedYear, holiday) {
var self = this,
holidayData = holiday.holidayData,
startDate = new Date(selectedYear, holidayData.fromMonth - 1, holidayData.fromDay);

return monster.util.dateToBeginningOfGregorianDay(startDate, monster.util.getCurrentTimeZone());
},

/**
* Returns Date
* @param {string} endYear
Expand Down Expand Up @@ -1044,7 +1058,7 @@ define(function(require) {
id = holidayData.id,
endDate = holidayData.recurring
? null
: monster.util.dateToEndOfGregorianDay(self.strategyHolidaysGetEndDate(holidayData.endYear, holiday)),
: monster.util.dateToEndOfGregorianDay(self.strategyHolidaysGetEndDate(holidayData.endYear, holiday), monster.util.getCurrentTimeZone()),
holidayRuleConfig = _.merge({
oldType: holidayData.set ? 'set' : 'rule'
}, id && {
Expand All @@ -1056,6 +1070,7 @@ define(function(require) {
'time_window_start',
'time_window_stop'
]), endDate && {
start_date: self.strategyHolidaysGetStartDate(holidayData.endYear, holiday),
end_date: endDate
}),
holidayRule = {};
Expand All @@ -1072,7 +1087,7 @@ define(function(require) {
} else {
holidayRule = _.merge({}, holidayRuleConfig, {
name: name,
cycle: 'yearly',
cycle: holidayData.recurring ? 'yearly' : 'date',
interval: 1,
month: month,
type: 'main_holidays'
Expand Down Expand Up @@ -1134,10 +1149,11 @@ define(function(require) {
days = _.range(fromDay, toDay + 1),
rule = {
name: name + '_' + month,
cycle: 'yearly',
cycle: data.start_date ? 'date' : 'yearly',
days: days,
interval: 1,
month: month
month: month,
start_date: data.start_date
};

if (data.exclude) {
Expand Down

0 comments on commit 4213582

Please sign in to comment.