UNPKG

@nesto-software/moment-holiday-sweden

Version:

The swedish locale for moment-holiday.

48 lines 2.26 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var moment = require("moment"); var moment_holiday_core_1 = require("@nesto-software/moment-holiday-core"); var MidsummerDependentDate = /** @class */ (function (_super) { __extends(MidsummerDependentDate, _super); /** * Create a new midsummer dependent date. * @param offset number of days before or after midsummer day - positive number means after, negative number before midsummer day */ function MidsummerDependentDate(offset) { var _this = _super.call(this) || this; _this.offset = offset; return _this; } MidsummerDependentDate.prototype.resolve = function (year) { // Midsommardagen occurs on the saturday that exists during the period 20 - 26 june var jun20 = moment({ year: year, month: 5, day: 20 }); var midsummerMoment = jun20; if (jun20.isoWeekday() == 7) { // June 20 is a sunday, Midsommardagen can only be on the 26th of june midsummerMoment = moment({ year: year, month: 5, day: 26 }); } else if (jun20.isoWeekday() < 6) { // June 20 is monday-friday, calculate how many days until saturday var day = 20 + (6 - jun20.isoWeekday()); midsummerMoment = moment({ year: year, month: 5, day: day }); } midsummerMoment.add(this.offset, "days"); // the moment setter has side effects return midsummerMoment; }; return MidsummerDependentDate; }(moment_holiday_core_1.AbstractDate)); exports.MidsummerDependentDate = MidsummerDependentDate; //# sourceMappingURL=midsummer-dependent-date.js.map