feat: add TurkeyHolidayHelper to exclude official holidays from intern day calculations and logs
This commit is contained in:
@@ -1485,6 +1485,41 @@
|
||||
}
|
||||
}
|
||||
|
||||
function isTurkeyHoliday(dateObj) {
|
||||
const yyyy = dateObj.getFullYear();
|
||||
const mm = String(dateObj.getMonth() + 1).padStart(2, '0');
|
||||
const dd = String(dateObj.getDate()).padStart(2, '0');
|
||||
const ymd = `${yyyy}-${mm}-${dd}`;
|
||||
const md = `${mm}-${dd}`;
|
||||
|
||||
const fixedHolidays = [
|
||||
'01-01', '04-23', '05-01', '05-19', '07-15', '08-30', '10-29'
|
||||
];
|
||||
|
||||
if (fixedHolidays.includes(md)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const variableHolidays = [
|
||||
'2024-04-09', '2024-04-10', '2024-04-11', '2024-04-12',
|
||||
'2024-06-15', '2024-06-16', '2024-06-17', '2024-06-18', '2024-06-19',
|
||||
'2025-03-29', '2025-03-30', '2025-03-31', '2025-04-01',
|
||||
'2025-06-05', '2025-06-06', '2025-06-07', '2025-06-08', '2025-06-09',
|
||||
'2026-03-19', '2026-03-20', '2026-03-21', '2026-03-22',
|
||||
'2026-05-26', '2026-05-27', '2026-05-28', '2026-05-29', '2026-05-30',
|
||||
'2027-03-08', '2027-03-09', '2027-03-10', '2027-03-11',
|
||||
'2027-05-15', '2027-05-16', '2027-05-17', '2027-05-18', '2027-05-19',
|
||||
'2028-02-26', '2028-02-27', '2028-02-28', '2028-02-29',
|
||||
'2028-05-04', '2028-05-05', '2028-05-06', '2028-05-07', '2028-05-08',
|
||||
'2029-02-14', '2029-02-15', '2029-02-16', '2029-02-17',
|
||||
'2029-04-23', '2029-04-24', '2029-04-25', '2029-04-26', '2029-04-27',
|
||||
'2030-02-03', '2030-02-04', '2030-02-05', '2030-02-06',
|
||||
'2030-04-12', '2030-04-13', '2030-04-14', '2030-04-15', '2030-04-16'
|
||||
];
|
||||
|
||||
return variableHolidays.includes(ymd);
|
||||
}
|
||||
|
||||
function calculateEndDateFrontend() {
|
||||
const startDateVal = document.getElementById('internship_start_date').value;
|
||||
const totalDaysVal = document.getElementById('internship_total_days').value;
|
||||
@@ -1501,7 +1536,7 @@
|
||||
|
||||
while (count < daysToAdd) {
|
||||
const dayOfWeek = date.getDay();
|
||||
if (dayOfWeek === 6 || dayOfWeek === 0) { // 6 = Saturday, 0 = Sunday
|
||||
if (dayOfWeek === 6 || dayOfWeek === 0 || isTurkeyHoliday(date)) { // 6 = Saturday, 0 = Sunday
|
||||
date.setDate(date.getDate() + 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user