UNPKG

retail-calendar

Version:
23 lines (22 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var date_utils_1 = require("./date_utils"); var FirstBOWOfFirstMonth = /** @class */ (function () { function FirstBOWOfFirstMonth() { } FirstBOWOfFirstMonth.prototype.getLastDayForGregorianLastDay = function (lastDayOfGregorianYear, lastDayOfIsoWeek, _retailCalendarYear) { var firstDayOfIsoWeek = lastDayOfIsoWeek === 7 ? 1 : lastDayOfIsoWeek + 1; // Go to the next month, i.e start month of next year var mutableLastDay = date_utils_1.addDaysToDate(lastDayOfGregorianYear, 1); // Find the first day which is a start of the week while (date_utils_1.getIsoWeekDay(mutableLastDay) !== firstDayOfIsoWeek) { mutableLastDay = date_utils_1.addDaysToDate(mutableLastDay, 1); } // That was the start of next year // Go back by one day and find end of this year. mutableLastDay = date_utils_1.addDaysToDate(mutableLastDay, -1); return mutableLastDay; }; return FirstBOWOfFirstMonth; }()); exports.FirstBOWOfFirstMonth = FirstBOWOfFirstMonth;