UNPKG

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