1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229 | 1×
1×
1×
1×
1×
1722×
1×
5579×
1×
17978×
1×
209×
1×
94×
1×
2162×
1×
2254×
1×
31150×
1×
249×
1×
4223×
1×
11201×
1×
9553×
9553×
1×
39463×
1×
945×
1×
1555×
519×
1036×
1×
500×
500×
500×
500×
500×
1×
410×
1×
6951×
1×
5007×
1×
4701×
1×
14146×
1×
116×
1×
7×
1×
1×
1×
1×
1×
1183×
1183×
1183×
1×
2201×
2201×
2201×
2201×
2201×
2201×
2201×
622×
1579×
1579×
1139×
440×
1×
818×
818×
1×
122×
1×
88×
88×
1×
12×
12×
1×
30×
30×
1×
31197×
31197×
1×
219×
219×
219×
1×
2114×
2114×
2114×
1×
835×
835×
1×
12×
12×
12×
1×
18764×
18764×
18764×
1643×
1643×
18764×
1×
242×
242×
242×
1×
1104×
1104×
1104×
1104×
1×
107×
107×
107×
1×
86×
86×
86×
1×
4280×
4280×
4280×
1×
4190×
4190×
1×
4480×
4480×
4480×
1×
10433×
10433×
10433×
1×
76×
76×
1×
1539×
1×
260×
1×
2201×
2201×
2201×
39×
2201×
1×
104597×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base"], function (require, exports, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Gregorian = (function () {
function Gregorian() {
}
Gregorian.prototype.firstDateOfMonth = function (date) {
return new Date(date.getFullYear(), date.getMonth());
};
Gregorian.prototype.lastDateOfMonth = function (dt) {
return new Date(dt.getFullYear(), dt.getMonth() + 1, 0);
};
Gregorian.prototype.isMonthStart = function (date) {
return (date.getDate() === 1);
};
Gregorian.prototype.getLeapYearDaysCount = function () {
return 366;
};
Gregorian.prototype.getYearDaysCount = function (date, interval) {
return ((date.getFullYear() + interval) % 4 === 0) ? 366 : 365;
};
Gregorian.prototype.getDate = function (date) {
return date.getDate();
};
Gregorian.prototype.getMonth = function (date) {
return (date.getMonth() + 1);
};
Gregorian.prototype.getFullYear = function (date) {
return date.getFullYear();
};
Gregorian.prototype.getYearLastDate = function (date, interval) {
return new Date(date.getFullYear() + interval, 0, 0);
};
Gregorian.prototype.getMonthDaysCount = function (date) {
return this.lastDateOfMonth(date).getDate();
};
Gregorian.prototype.getMonthStartDate = function (date) {
return new Date(date.getFullYear(), date.getMonth(), 1, date.getHours(), date.getMinutes());
};
Gregorian.prototype.getMonthEndDate = function (date) {
date.setDate(1);
return new Date(date.setMonth(date.getMonth() + 1));
};
Gregorian.prototype.getExpectedDays = function (date, days) {
return days;
};
Gregorian.prototype.setDate = function (dateObj, date) {
dateObj.setDate(date);
};
Gregorian.prototype.setValidDate = function (date, interval, startDate, monthValue, beginDate) {
if (!ej2_base_1.isNullOrUndefined(beginDate)) {
date.setMonth((beginDate ? monthValue : date.getMonth()) + interval);
}
else {
date.setMonth(date.getMonth() + interval, startDate);
}
};
Gregorian.prototype.setMonth = function (date, interval, startDate) {
date.setDate(1);
date.setFullYear(date.getFullYear());
date.setMonth(interval - 1);
var maxDay = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
date.setDate(Math.min(startDate, maxDay));
};
Gregorian.prototype.addYears = function (date, interval) {
date.setFullYear(date.getFullYear() + interval);
};
Gregorian.prototype.isSameMonth = function (date1, date2) {
return (date1.getMonth() === date2.getMonth());
};
Gregorian.prototype.checkMonth = function (date, months) {
return (months.indexOf(date.getMonth() + 1) === -1);
};
Gregorian.prototype.compareMonth = function (date1, date2) {
return (date1.getMonth() > date2.getMonth());
};
Gregorian.prototype.isSameYear = function (date1, date2) {
return (date1.getFullYear() === date2.getFullYear());
};
Gregorian.prototype.isLastMonth = function (date) {
return (date.getMonth() === 11);
};
Gregorian.prototype.isLeapYear = function (year, interval) {
return ((year + interval) % 4 === 0);
};
return Gregorian;
}());
exports.Gregorian = Gregorian;
var Islamic = (function () {
function Islamic() {
}
Islamic.prototype.firstDateOfMonth = function (date) {
var hDate = this.getHijriDate(date);
var gDate = ej2_base_1.HijriParser.toGregorian(hDate.year, hDate.month, 1);
return gDate;
};
Islamic.prototype.lastDateOfMonth = function (date) {
var hDate = this.getHijriDate(date);
var daysInMonth = this.getDaysInMonth(hDate.month, hDate.year);
var gDate = ej2_base_1.HijriParser.toGregorian(hDate.year, hDate.month, daysInMonth);
var finalGDate = new Date(gDate.getTime());
finalGDate = new Date(finalGDate.setDate(finalGDate.getDate() + 1));
var finalHDate = this.getHijriDate(finalGDate);
if (hDate.month === finalHDate.month) {
return finalGDate;
}
finalHDate = this.getHijriDate(gDate);
if (hDate.month === finalHDate.month) {
return gDate;
}
return new Date(gDate.setDate(gDate.getDate() - 1));
};
Islamic.prototype.isMonthStart = function (date) {
var hijriDate = this.getHijriDate(date);
return (hijriDate.date === 1);
};
Islamic.prototype.getLeapYearDaysCount = function () {
return 355;
};
Islamic.prototype.getYearDaysCount = function (date, interval) {
var hDate = this.getHijriDate(date);
return this.isLeapYear(hDate.year, interval) ? 355 : 354;
};
Islamic.prototype.getDate = function (date) {
var hijriDate = this.getHijriDate(date);
return hijriDate.date;
};
Islamic.prototype.getMonth = function (date) {
var hDate = this.getHijriDate(date);
return hDate.month;
};
Islamic.prototype.getFullYear = function (date) {
var hDate = this.getHijriDate(date);
return hDate.year;
};
Islamic.prototype.getYearLastDate = function (date, interval) {
var hDate = this.getHijriDate(date);
var gDate = ej2_base_1.HijriParser.toGregorian(hDate.year + interval, 1, 0);
return gDate;
};
Islamic.prototype.getMonthDaysCount = function (date) {
var maxDate = this.lastDateOfMonth(date);
var hijriDate = this.getHijriDate(maxDate);
return hijriDate.date;
};
Islamic.prototype.getMonthStartDate = function (date) {
var firstDate = this.firstDateOfMonth(date);
return new Date(firstDate.getFullYear(), firstDate.getMonth(), firstDate.getDate(), date.getHours(), date.getMinutes());
};
Islamic.prototype.getMonthEndDate = function (date) {
var lastDate = this.lastDateOfMonth(date);
lastDate.setDate(lastDate.getDate() + 1);
return new Date(lastDate.setMonth(lastDate.getMonth()));
};
Islamic.prototype.getExpectedDays = function (date, days) {
var hDate = this.getHijriDate(date);
var day = [];
for (var i = 0; i < days.length; i++) {
var gDate = ej2_base_1.HijriParser.toGregorian(hDate.year, hDate.month, days[parseInt(i.toString(), 10)]);
day.push(gDate.getDate());
}
return day;
};
Islamic.prototype.setDate = function (dateObj, date) {
var hDate = this.getHijriDate(dateObj);
var gDate = ej2_base_1.HijriParser.toGregorian(hDate.year, hDate.month, date);
this.updateDateObj(dateObj, gDate);
};
Islamic.prototype.setValidDate = function (date, interval, startDate, monthValue, beginDate) {
var firstDate = (!ej2_base_1.isNullOrUndefined(beginDate)) ? this.firstDateOfMonth(beginDate) : date;
var hDate = this.getHijriDate(firstDate);
var gDate = ej2_base_1.HijriParser.toGregorian(hDate.year, hDate.month + interval, startDate);
this.updateDateObj(date, gDate);
};
Islamic.prototype.setMonth = function (date, interval, startDate) {
var hDate = this.getHijriDate(date);
var gDate = ej2_base_1.HijriParser.toGregorian(hDate.year, interval, startDate);
this.updateDateObj(date, gDate);
};
Islamic.prototype.addYears = function (date, interval, monthValue) {
var hDate = this.getHijriDate(date);
var gDate = ej2_base_1.HijriParser.toGregorian(hDate.year + interval, monthValue, 1);
this.updateDateObj(date, gDate);
};
Islamic.prototype.isSameMonth = function (date1, date2) {
var currentHijri = this.getHijriDate(date1);
var tempHijri = this.getHijriDate(date2);
return (currentHijri.month === tempHijri.month);
};
Islamic.prototype.checkMonth = function (date, months) {
var hDate = this.getHijriDate(date);
return (months.indexOf(hDate.month) === -1);
};
Islamic.prototype.compareMonth = function (date1, date2) {
var hDate = this.getHijriDate(date1);
var hDate1 = this.getHijriDate(date2);
return (hDate.month > hDate1.month);
};
Islamic.prototype.isSameYear = function (date1, date2) {
var hDate = this.getHijriDate(date1);
var hDate1 = this.getHijriDate(date2);
return (hDate.year === hDate1.year);
};
Islamic.prototype.isLastMonth = function (date) {
var hDate = this.getHijriDate(date);
return (hDate.month === 12);
};
Islamic.prototype.updateDateObj = function (date, gDate) {
date.setFullYear(gDate.getFullYear(), gDate.getMonth(), gDate.getDate());
};
Islamic.prototype.isLeapYear = function (year, interval) {
return (14 + 11 * (year + interval)) % 30 < 11;
};
Islamic.prototype.getDaysInMonth = function (month, year) {
var length = 0;
length = 29 + ((month + 1) % 2);
if (month === 11 && this.isLeapYear(year, 0)) {
length++;
}
return length;
};
Islamic.prototype.getHijriDate = function (date) {
return ej2_base_1.HijriParser.getHijriDate(date);
};
return Islamic;
}());
exports.Islamic = Islamic;
});
|