UNPKG

1.34 kBJavaScriptView Raw
1// =============================================================================
2// Weekday
3// =============================================================================
4export var ALL_WEEKDAYS = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'];
5var Weekday = /** @class */ (function () {
6 function Weekday(weekday, n) {
7 if (n === 0)
8 throw new Error("Can't create weekday with n == 0");
9 this.weekday = weekday;
10 this.n = n;
11 }
12 Weekday.fromStr = function (str) {
13 return new Weekday(ALL_WEEKDAYS.indexOf(str));
14 };
15 // __call__ - Cannot call the object directly, do it through
16 // e.g. RRule.TH.nth(-1) instead,
17 Weekday.prototype.nth = function (n) {
18 return this.n === n ? this : new Weekday(this.weekday, n);
19 };
20 // __eq__
21 Weekday.prototype.equals = function (other) {
22 return this.weekday === other.weekday && this.n === other.n;
23 };
24 // __repr__
25 Weekday.prototype.toString = function () {
26 var s = ALL_WEEKDAYS[this.weekday];
27 if (this.n)
28 s = (this.n > 0 ? '+' : '') + String(this.n) + s;
29 return s;
30 };
31 Weekday.prototype.getJsWeekday = function () {
32 return this.weekday === 6 ? 0 : this.weekday + 1;
33 };
34 return Weekday;
35}());
36export { Weekday };
37//# sourceMappingURL=weekday.js.map
\No newline at end of file