mumineen-ui-plugins 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -23,10 +23,10 @@ export declare class HijriCalendar {
|
|
|
23
23
|
getMinYear(): number;
|
|
24
24
|
getMaxYear(): number;
|
|
25
25
|
dayOfWeek(date: any): number;
|
|
26
|
-
days():
|
|
26
|
+
days(): Day[];
|
|
27
27
|
weeks(): any;
|
|
28
|
-
previousDays(): any;
|
|
29
|
-
nextDays(): any;
|
|
28
|
+
previousDays(): any[];
|
|
29
|
+
nextDays(): any[];
|
|
30
30
|
previousMonth(): HijriCalendar;
|
|
31
31
|
nextMonth(): HijriCalendar;
|
|
32
32
|
previousYear(): HijriCalendar;
|
|
@@ -2,9 +2,22 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HijriCalendar = void 0;
|
|
4
4
|
const HijriDate_1 = require("./HijriDate");
|
|
5
|
-
const lazy_js_1 = require("lazy.js");
|
|
6
5
|
const MIN_CALENDAR_YEAR = 1000;
|
|
7
6
|
const MAX_CALENDAR_YEAR = 3000;
|
|
7
|
+
const range = (n) => Array.from(Array(n).keys());
|
|
8
|
+
const repeat = (value, count) => range(count).map(() => value);
|
|
9
|
+
const concat = (...arrays) => arrays.reduce((acc, curr) => {
|
|
10
|
+
acc.push(...curr);
|
|
11
|
+
return acc;
|
|
12
|
+
}, []);
|
|
13
|
+
Object.defineProperty(Array.prototype, "chunk", {
|
|
14
|
+
value: function (chunkSize) {
|
|
15
|
+
var R = [];
|
|
16
|
+
for (var i = 0; i < this.length; i += chunkSize)
|
|
17
|
+
R.push(this.slice(i, i + chunkSize));
|
|
18
|
+
return R;
|
|
19
|
+
},
|
|
20
|
+
});
|
|
8
21
|
class HijriCalendar {
|
|
9
22
|
constructor(year, month, iso8601 = false) {
|
|
10
23
|
this.year = year;
|
|
@@ -34,36 +47,36 @@ class HijriCalendar {
|
|
|
34
47
|
// return array of days of this month and year
|
|
35
48
|
days() {
|
|
36
49
|
const self = this;
|
|
37
|
-
return
|
|
50
|
+
return range(HijriDate_1.HijriDate.daysInMonth(this.year, this.month)).map(function (day) {
|
|
38
51
|
var hijriDate = new HijriDate_1.HijriDate(self.year, self.month, day + 1), gregorianDate = hijriDate.toGregorian();
|
|
39
52
|
return self.dayHash(hijriDate, gregorianDate);
|
|
40
|
-
}
|
|
53
|
+
});
|
|
41
54
|
}
|
|
42
55
|
// return array of weeks for this month and year
|
|
43
56
|
weeks() {
|
|
44
|
-
return
|
|
57
|
+
return concat(this.previousDays(), this.days(), this.nextDays()).chunk(7);
|
|
45
58
|
}
|
|
46
59
|
// return array of days from beginning of week until start of this month and year
|
|
47
60
|
previousDays() {
|
|
48
61
|
var previousMonth = this.previousMonth(), daysInPreviousMonth = HijriDate_1.HijriDate.daysInMonth(previousMonth.getYear(), previousMonth.getMonth()), dayAtStartOfMonth = this.dayOfWeek(1);
|
|
49
62
|
if (this.month === 0 && this.year === MIN_CALENDAR_YEAR)
|
|
50
|
-
return
|
|
63
|
+
return repeat(null, 6 - dayAtStartOfMonth);
|
|
51
64
|
const self = this;
|
|
52
|
-
return
|
|
65
|
+
return range(dayAtStartOfMonth).map(function (day) {
|
|
53
66
|
const hijriDate = new HijriDate_1.HijriDate(previousMonth.getYear(), previousMonth.getMonth(), daysInPreviousMonth - dayAtStartOfMonth + day + 1), gregorianDate = hijriDate.toGregorian();
|
|
54
67
|
return self.dayHash(hijriDate, gregorianDate, true);
|
|
55
|
-
}
|
|
68
|
+
});
|
|
56
69
|
}
|
|
57
70
|
// return array of days from end of this month and year until end of the week
|
|
58
71
|
nextDays() {
|
|
59
72
|
var nextMonth = this.nextMonth(), daysInMonth = HijriDate_1.HijriDate.daysInMonth(this.year, this.month), dayAtEndOfMonth = this.dayOfWeek(daysInMonth);
|
|
60
73
|
if (nextMonth.getYear() === this.year && nextMonth.getMonth() === this.month)
|
|
61
|
-
return
|
|
74
|
+
return repeat(null, 6 - dayAtEndOfMonth);
|
|
62
75
|
const self = this;
|
|
63
|
-
return
|
|
76
|
+
return range(6 - dayAtEndOfMonth).map(function (day) {
|
|
64
77
|
var hijriDate = new HijriDate_1.HijriDate(nextMonth.getYear(), nextMonth.getMonth(), day + 1), gregorianDate = hijriDate.toGregorian();
|
|
65
78
|
return self.dayHash(hijriDate, gregorianDate, true);
|
|
66
|
-
}
|
|
79
|
+
});
|
|
67
80
|
}
|
|
68
81
|
// return Hijri Calendar object for the previous month
|
|
69
82
|
previousMonth() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mumineen-ui-plugins",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"scripts": {
|
|
@@ -50,7 +50,5 @@
|
|
|
50
50
|
"url": "https://github.com/navedr/mumineen-ui-plugins/issues"
|
|
51
51
|
},
|
|
52
52
|
"homepage": "https://github.com/navedr/mumineen-ui-plugins#readme",
|
|
53
|
-
"dependencies": {
|
|
54
|
-
"lazy.js": "^0.5.1"
|
|
55
|
-
}
|
|
53
|
+
"dependencies": {}
|
|
56
54
|
}
|