@acorex/core 7.1.52 → 7.2.1
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.
- package/README.md +3 -20
- package/config/README.md +3 -0
- package/config/index.d.ts +2 -5
- package/config/lib/configs.service.d.ts +5 -0
- package/dateTime/README.md +3 -0
- package/dateTime/index.d.ts +5 -5
- package/dateTime/{src → lib}/jalali.calendar.d.ts +1 -1
- package/esm2022/acorex-core.mjs +2 -2
- package/esm2022/config/acorex-core-config.mjs +2 -2
- package/esm2022/config/index.mjs +3 -0
- package/esm2022/config/lib/configs.mjs +24 -0
- package/esm2022/config/lib/configs.service.mjs +11 -0
- package/esm2022/dateTime/acorex-core-dateTime.mjs +2 -2
- package/esm2022/dateTime/index.mjs +6 -0
- package/esm2022/dateTime/lib/datetime.class.mjs +288 -0
- package/esm2022/dateTime/lib/datetime.module.mjs +39 -0
- package/esm2022/dateTime/lib/datetime.pipe.mjs +26 -0
- package/esm2022/dateTime/lib/georgian.calendar.mjs +189 -0
- package/esm2022/dateTime/lib/jalali.calendar.mjs +355 -0
- package/esm2022/events/acorex-core-events.mjs +2 -2
- package/esm2022/events/index.mjs +2 -0
- package/esm2022/events/lib/event.service.mjs +36 -0
- package/esm2022/file/acorex-core-file.mjs +2 -2
- package/esm2022/file/index.mjs +5 -0
- package/esm2022/file/lib/file-download-ref.class.mjs +12 -0
- package/esm2022/file/lib/file-download-result.class.mjs +46 -0
- package/esm2022/file/lib/file-upload-ref.class.mjs +12 -0
- package/esm2022/file/lib/file.service.mjs +102 -0
- package/esm2022/http/acorex-core-http.mjs +2 -2
- package/esm2022/http/index.mjs +7 -0
- package/esm2022/http/lib/http-error.class.mjs +2 -0
- package/esm2022/http/lib/http-events.interceptor.mjs +3 -0
- package/esm2022/http/lib/http-request.class.mjs +2 -0
- package/esm2022/http/lib/http-result.class.mjs +21 -0
- package/esm2022/http/lib/http.module.mjs +29 -0
- package/esm2022/http/lib/http.service.mjs +148 -0
- package/esm2022/image/acorex-core-image.mjs +2 -2
- package/esm2022/image/index.mjs +2 -0
- package/esm2022/image/lib/image.service.mjs +43 -0
- package/esm2022/index.mjs +2 -0
- package/esm2022/pipes/acorex-core-pipes.mjs +2 -2
- package/esm2022/pipes/index.mjs +3 -0
- package/esm2022/pipes/lib/pipes.module.mjs +19 -0
- package/esm2022/pipes/lib/safe.pipe.mjs +31 -0
- package/esm2022/platform/acorex-core-platform.mjs +2 -2
- package/esm2022/platform/index.mjs +2 -0
- package/esm2022/platform/lib/platform.service.mjs +155 -0
- package/esm2022/translation/acorex-core-translation.mjs +2 -2
- package/esm2022/translation/index.mjs +4 -0
- package/esm2022/translation/lib/translation.module.mjs +18 -0
- package/esm2022/translation/lib/translator.mjs +43 -0
- package/esm2022/translation/lib/translator.pipe.mjs +15 -0
- package/esm2022/utils/acorex-core-utils.mjs +2 -2
- package/esm2022/utils/index.mjs +6 -0
- package/esm2022/utils/lib/color-util.mjs +115 -0
- package/esm2022/utils/lib/drawing-util.mjs +29 -0
- package/esm2022/utils/lib/html-util.mjs +16 -0
- package/esm2022/utils/lib/object-util.mjs +39 -0
- package/esm2022/utils/lib/string-util.mjs +19 -0
- package/events/README.md +3 -0
- package/events/index.d.ts +1 -5
- package/fesm2022/acorex-core-config.mjs +14 -3
- package/fesm2022/acorex-core-config.mjs.map +1 -1
- package/fesm2022/acorex-core-dateTime.mjs +171 -178
- package/fesm2022/acorex-core-dateTime.mjs.map +1 -1
- package/fesm2022/acorex-core-events.mjs +6 -4
- package/fesm2022/acorex-core-events.mjs.map +1 -1
- package/fesm2022/acorex-core-file.mjs +19 -23
- package/fesm2022/acorex-core-file.mjs.map +1 -1
- package/fesm2022/acorex-core-http.mjs +10 -17
- package/fesm2022/acorex-core-http.mjs.map +1 -1
- package/fesm2022/acorex-core-image.mjs +3 -3
- package/fesm2022/acorex-core-image.mjs.map +1 -1
- package/fesm2022/acorex-core-pipes.mjs +8 -9
- package/fesm2022/acorex-core-pipes.mjs.map +1 -1
- package/fesm2022/acorex-core-platform.mjs +6 -8
- package/fesm2022/acorex-core-platform.mjs.map +1 -1
- package/fesm2022/acorex-core-translation.mjs +13 -13
- package/fesm2022/acorex-core-translation.mjs.map +1 -1
- package/fesm2022/acorex-core-utils.mjs +87 -87
- package/fesm2022/acorex-core-utils.mjs.map +1 -1
- package/fesm2022/acorex-core.mjs +1 -6
- package/fesm2022/acorex-core.mjs.map +1 -1
- package/file/README.md +3 -0
- package/file/index.d.ts +4 -5
- package/http/README.md +3 -0
- package/http/index.d.ts +6 -5
- package/image/README.md +3 -0
- package/image/index.d.ts +1 -5
- package/index.d.ts +2 -5
- package/package.json +13 -11
- package/pipes/README.md +3 -0
- package/pipes/index.d.ts +2 -5
- package/platform/README.md +3 -0
- package/platform/index.d.ts +1 -5
- package/translation/README.md +3 -0
- package/translation/index.d.ts +3 -5
- package/utils/README.md +3 -0
- package/utils/index.d.ts +5 -5
- package/config/public-api.d.ts +0 -1
- package/dateTime/public-api.d.ts +0 -5
- package/esm2022/config/public-api.mjs +0 -2
- package/esm2022/config/src/configs.mjs +0 -25
- package/esm2022/dateTime/public-api.mjs +0 -6
- package/esm2022/dateTime/src/datetime.class.mjs +0 -295
- package/esm2022/dateTime/src/datetime.module.mjs +0 -40
- package/esm2022/dateTime/src/datetime.pipe.mjs +0 -27
- package/esm2022/dateTime/src/georgian.calendar.mjs +0 -187
- package/esm2022/dateTime/src/jalali.calendar.mjs +0 -357
- package/esm2022/events/public-api.mjs +0 -2
- package/esm2022/events/src/event.service.mjs +0 -35
- package/esm2022/file/public-api.mjs +0 -5
- package/esm2022/file/src/file-download-ref.class.mjs +0 -13
- package/esm2022/file/src/file-download-result.class.mjs +0 -47
- package/esm2022/file/src/file-upload-ref.class.mjs +0 -13
- package/esm2022/file/src/file.service.mjs +0 -103
- package/esm2022/http/public-api.mjs +0 -6
- package/esm2022/http/src/http-error.class.mjs +0 -2
- package/esm2022/http/src/http-events.interceptor.mjs +0 -3
- package/esm2022/http/src/http-request.class.mjs +0 -2
- package/esm2022/http/src/http-result.class.mjs +0 -25
- package/esm2022/http/src/http.module.mjs +0 -30
- package/esm2022/http/src/http.service.mjs +0 -152
- package/esm2022/image/public-api.mjs +0 -2
- package/esm2022/image/src/image.service.mjs +0 -44
- package/esm2022/pipes/public-api.mjs +0 -3
- package/esm2022/pipes/src/pipes.module.mjs +0 -20
- package/esm2022/pipes/src/safe.pipe.mjs +0 -32
- package/esm2022/platform/public-api.mjs +0 -2
- package/esm2022/platform/src/platform.service.mjs +0 -158
- package/esm2022/public-api.mjs +0 -5
- package/esm2022/translation/public-api.mjs +0 -4
- package/esm2022/translation/src/translation.module.mjs +0 -19
- package/esm2022/translation/src/translator.mjs +0 -44
- package/esm2022/translation/src/translator.pipe.mjs +0 -16
- package/esm2022/utils/public-api.mjs +0 -6
- package/esm2022/utils/src/color-util.mjs +0 -115
- package/esm2022/utils/src/drawing-util.mjs +0 -29
- package/esm2022/utils/src/html-util.mjs +0 -16
- package/esm2022/utils/src/object-util.mjs +0 -39
- package/esm2022/utils/src/string-util.mjs +0 -19
- package/events/public-api.d.ts +0 -1
- package/file/public-api.d.ts +0 -4
- package/http/public-api.d.ts +0 -5
- package/image/public-api.d.ts +0 -1
- package/pipes/public-api.d.ts +0 -2
- package/platform/public-api.d.ts +0 -1
- package/public-api.d.ts +0 -1
- package/translation/public-api.d.ts +0 -3
- package/utils/public-api.d.ts +0 -5
- /package/config/{src → lib}/configs.d.ts +0 -0
- /package/dateTime/{src → lib}/datetime.class.d.ts +0 -0
- /package/dateTime/{src → lib}/datetime.module.d.ts +0 -0
- /package/dateTime/{src → lib}/datetime.pipe.d.ts +0 -0
- /package/dateTime/{src → lib}/georgian.calendar.d.ts +0 -0
- /package/events/{src → lib}/event.service.d.ts +0 -0
- /package/file/{src → lib}/file-download-ref.class.d.ts +0 -0
- /package/file/{src → lib}/file-download-result.class.d.ts +0 -0
- /package/file/{src → lib}/file-upload-ref.class.d.ts +0 -0
- /package/file/{src → lib}/file.service.d.ts +0 -0
- /package/http/{src → lib}/http-error.class.d.ts +0 -0
- /package/http/{src → lib}/http-events.interceptor.d.ts +0 -0
- /package/http/{src → lib}/http-request.class.d.ts +0 -0
- /package/http/{src → lib}/http-result.class.d.ts +0 -0
- /package/http/{src → lib}/http.module.d.ts +0 -0
- /package/http/{src → lib}/http.service.d.ts +0 -0
- /package/image/{src → lib}/image.service.d.ts +0 -0
- /package/pipes/{src → lib}/pipes.module.d.ts +0 -0
- /package/pipes/{src → lib}/safe.pipe.d.ts +0 -0
- /package/platform/{src → lib}/platform.service.d.ts +0 -0
- /package/translation/{src → lib}/translation.module.d.ts +0 -0
- /package/translation/{src → lib}/translator.d.ts +0 -0
- /package/translation/{src → lib}/translator.pipe.d.ts +0 -0
- /package/utils/{src → lib}/color-util.d.ts +0 -0
- /package/utils/{src → lib}/drawing-util.d.ts +0 -0
- /package/utils/{src → lib}/html-util.d.ts +0 -0
- /package/utils/{src → lib}/object-util.d.ts +0 -0
- /package/utils/{src → lib}/string-util.d.ts +0 -0
@@ -26,7 +26,7 @@ class AXDateTime {
|
|
26
26
|
hours: 0,
|
27
27
|
minutes: 0,
|
28
28
|
seconds: 0,
|
29
|
-
ms: 0
|
29
|
+
ms: 0,
|
30
30
|
}) {
|
31
31
|
return AXDateTime.resolveCalendar(value.calendar).create(value);
|
32
32
|
}
|
@@ -35,15 +35,44 @@ class AXDateTime {
|
|
35
35
|
? AXConfig.get(`dateTime.calendars.${calendar}.class`)
|
36
36
|
: calendar;
|
37
37
|
}
|
38
|
-
_date;
|
39
38
|
get date() {
|
40
39
|
return this._date;
|
41
40
|
}
|
42
|
-
_calendar;
|
43
41
|
get calendar() {
|
44
42
|
return this._calendar;
|
45
43
|
}
|
46
44
|
constructor(value = new Date(), calendar = AXConfig.get(`dateTime.calendar`)) {
|
45
|
+
this._formatKeys = {
|
46
|
+
ss: () => this.pad(this.date.getSeconds(), 2),
|
47
|
+
s: () => this.date.getSeconds().toString(),
|
48
|
+
//
|
49
|
+
dd: () => this.pad(this.calendar.dayOfMonth(this.date), 2),
|
50
|
+
d: () => this.calendar.dayOfMonth(this.date).toString(),
|
51
|
+
//
|
52
|
+
mm: () => this.pad(this.date.getMinutes(), 2),
|
53
|
+
m: () => this.date.getMinutes().toString(),
|
54
|
+
//
|
55
|
+
MMMM: () => this.calendar.monthNames[this.calendar.monthOfYear(this.date) - 1],
|
56
|
+
MMM: () => this.calendar.monthShortNames[this.calendar.monthOfYear(this.date) - 1],
|
57
|
+
MM: () => this.pad(this.calendar.monthOfYear(this.date), 2),
|
58
|
+
//
|
59
|
+
DDDD: () => this.calendar.dayNames[this.calendar.dayOfWeek(this.date) - 1],
|
60
|
+
DDD: () => this.calendar.dayShortNames[this.calendar.dayOfWeek(this.date) - 1],
|
61
|
+
//
|
62
|
+
yyyy: () => this.calendar.year(this.date).toString(),
|
63
|
+
YYYY: () => this.calendar.year(this.date).toString(),
|
64
|
+
yy: () => this.calendar.year(this.date).toString().substring(2),
|
65
|
+
YY: () => this.calendar.year(this.date).toString().substring(2),
|
66
|
+
//
|
67
|
+
HH: () => this.pad(this.date.getHours(), 2),
|
68
|
+
H: () => this.date.getHours().toString(),
|
69
|
+
//
|
70
|
+
hh: () => this.pad(this.date.getHours() % 12 || 12, 2),
|
71
|
+
h: () => (this.date.getHours() % 12 || 12).toString(),
|
72
|
+
//
|
73
|
+
A: () => (this.date.getHours() < 12 ? 'am' : 'pm'),
|
74
|
+
a: () => (this.date.getHours() < 12 ? 'am' : 'pm'),
|
75
|
+
};
|
47
76
|
this._calendar = AXDateTime.resolveCalendar(calendar);
|
48
77
|
if (value instanceof Date) {
|
49
78
|
this._date = value;
|
@@ -102,39 +131,8 @@ class AXDateTime {
|
|
102
131
|
endOf(unit = 'day') {
|
103
132
|
return this._calendar.endOf(this.date, unit);
|
104
133
|
}
|
105
|
-
_formatKeys = {
|
106
|
-
ss: () => this.pad(this.date.getSeconds(), 2),
|
107
|
-
s: () => this.date.getSeconds().toString(),
|
108
|
-
//
|
109
|
-
dd: () => this.pad(this.calendar.dayOfMonth(this.date), 2),
|
110
|
-
d: () => this.calendar.dayOfMonth(this.date).toString(),
|
111
|
-
//
|
112
|
-
mm: () => this.pad(this.date.getMinutes(), 2),
|
113
|
-
m: () => this.date.getMinutes().toString(),
|
114
|
-
//
|
115
|
-
MMMM: () => this.calendar.monthNames[this.calendar.monthOfYear(this.date) - 1],
|
116
|
-
MMM: () => this.calendar.monthShortNames[this.calendar.monthOfYear(this.date) - 1],
|
117
|
-
MM: () => this.pad(this.calendar.monthOfYear(this.date), 2),
|
118
|
-
//
|
119
|
-
DDDD: () => this.calendar.dayNames[this.calendar.dayOfWeek(this.date) - 1],
|
120
|
-
DDD: () => this.calendar.dayShortNames[this.calendar.dayOfWeek(this.date) - 1],
|
121
|
-
//
|
122
|
-
yyyy: () => this.calendar.year(this.date).toString(),
|
123
|
-
YYYY: () => this.calendar.year(this.date).toString(),
|
124
|
-
yy: () => this.calendar.year(this.date).toString().substring(2),
|
125
|
-
YY: () => this.calendar.year(this.date).toString().substring(2),
|
126
|
-
//
|
127
|
-
HH: () => this.pad(this.date.getHours(), 2),
|
128
|
-
H: () => this.date.getHours().toString(),
|
129
|
-
//
|
130
|
-
hh: () => this.pad((this.date.getHours() % 12 || 12), 2),
|
131
|
-
h: () => (this.date.getHours() % 12 || 12).toString(),
|
132
|
-
//
|
133
|
-
A: () => (this.date.getHours() < 12) ? 'am' : 'pm',
|
134
|
-
a: () => (this.date.getHours() < 12) ? 'am' : 'pm',
|
135
|
-
};
|
136
134
|
format(format = AXConfig.get('dateTime.shortDateFormat')) {
|
137
|
-
const re = new RegExp(_.orderBy(Object.keys(this._formatKeys), c => c.length, ['desc']).join(
|
135
|
+
const re = new RegExp(_.orderBy(Object.keys(this._formatKeys), (c) => c.length, ['desc']).join('|'), 'gi');
|
138
136
|
return format.replace(re, (matched) => {
|
139
137
|
return this._formatKeys[matched]();
|
140
138
|
});
|
@@ -193,7 +191,6 @@ class AXDateTime {
|
|
193
191
|
}
|
194
192
|
}
|
195
193
|
class AXCalendarMonth {
|
196
|
-
_range;
|
197
194
|
get range() {
|
198
195
|
return this._range;
|
199
196
|
}
|
@@ -205,12 +202,8 @@ class AXCalendarMonth {
|
|
205
202
|
this.name = date.format('MMMM');
|
206
203
|
this.range = new AXDateTimeRange(new AXDateTime(date.startOf('month').date, date.calendar), new AXDateTime(date.endOf('month').date, date.calendar));
|
207
204
|
}
|
208
|
-
index;
|
209
|
-
name;
|
210
205
|
}
|
211
206
|
class AXDateTimeRange {
|
212
|
-
_startTime;
|
213
|
-
_endTime;
|
214
207
|
get startTime() {
|
215
208
|
return this._startTime;
|
216
209
|
}
|
@@ -283,7 +276,7 @@ class AXDateTimeRange {
|
|
283
276
|
const result = [];
|
284
277
|
let item = this._startTime.clone();
|
285
278
|
while (item.compare(this._endTime, unit) < 1) {
|
286
|
-
if (!result.some(c => c.equal(item, unit))) {
|
279
|
+
if (!result.some((c) => c.equal(item, unit))) {
|
287
280
|
result.push(item);
|
288
281
|
}
|
289
282
|
item = item.add(unit, amount);
|
@@ -310,35 +303,37 @@ class AXDateTimePipe {
|
|
310
303
|
return date.format(format);
|
311
304
|
}
|
312
305
|
}
|
313
|
-
static
|
314
|
-
static
|
306
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
307
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimePipe, name: "axDate" }); }
|
315
308
|
}
|
316
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.
|
309
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimePipe, decorators: [{
|
317
310
|
type: Pipe,
|
318
311
|
args: [{ name: 'axDate' }]
|
319
312
|
}], ctorParameters: function () { return []; } });
|
320
313
|
|
321
314
|
class GeorgianCalendar {
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
315
|
+
constructor() {
|
316
|
+
this.monthNames = [
|
317
|
+
"January", "February", "March",
|
318
|
+
"April", "May", "June", "July",
|
319
|
+
"August", "September", "October",
|
320
|
+
"November", "December"
|
321
|
+
];
|
322
|
+
this.monthShortNames = [
|
323
|
+
"Jan", "Feb", "Mar",
|
324
|
+
"Apr", "May", "Jun", "Jul",
|
325
|
+
"Aug", "Sep", "Oct",
|
326
|
+
"Nov", "Dec"
|
327
|
+
];
|
328
|
+
this.dayNames = [
|
329
|
+
"Sunday", "Monday", "Tuesday", "Wednesday",
|
330
|
+
"Thursday", "Friday", "Saturday"
|
331
|
+
];
|
332
|
+
this.dayShortNames = [
|
333
|
+
"Sun", "Mon", "Tue", "Wed",
|
334
|
+
"Thu", "Fri", "Sat"
|
335
|
+
];
|
336
|
+
}
|
342
337
|
create(value) {
|
343
338
|
return new AXDateTime(new Date(value.year, value.month - 1, value.date, value.hours || 0, value.minutes || 0, value.seconds || 0, value.ms || 0), this.name());
|
344
339
|
}
|
@@ -505,10 +500,12 @@ class GeorgianCalendar {
|
|
505
500
|
}
|
506
501
|
|
507
502
|
class JalaliCalendar {
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
503
|
+
constructor() {
|
504
|
+
this.monthNames = 'فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند'.split('_');
|
505
|
+
this.monthShortNames = 'فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند'.split('_');
|
506
|
+
this.dayNames = 'شنبه_یکشنبه_دوشنبه_سه شنبه_چهارشنبه_پنج شنبه_جمعه'.split('_');
|
507
|
+
this.dayShortNames = 'ش_ی_د_س_چ_پ_ج'.split('_');
|
508
|
+
}
|
512
509
|
create(value) {
|
513
510
|
const a = this.toGregorian(value.year, value.month, value.date);
|
514
511
|
return new AXDateTime(new Date(a.getFullYear(), a.getMonth(), a.getDate(), value.hours || 0, value.minutes || 0, value.seconds || 0, value.ms || 0), this.name());
|
@@ -521,7 +518,7 @@ class JalaliCalendar {
|
|
521
518
|
}
|
522
519
|
dayOfYear(date) {
|
523
520
|
const j = this.toJalali(date);
|
524
|
-
return (j.month <= 6 ? (
|
521
|
+
return (j.month <= 6 ? (j.month - 1) * 31 : 6 * 31 + (j.month - 7) * 30) + j.day;
|
525
522
|
}
|
526
523
|
dayOfWeek(date) {
|
527
524
|
return date.getDay() == 6 ? 1 : date.getDay() + 2;
|
@@ -529,7 +526,7 @@ class JalaliCalendar {
|
|
529
526
|
weekOfYear(date) {
|
530
527
|
//TODO : apply jalali
|
531
528
|
const firstDay = new AXDateTime(date).startOf('year');
|
532
|
-
return Math.ceil(((
|
529
|
+
return Math.ceil(((date.getTime() - firstDay.date.getTime()) / 86400000 + firstDay.date.getDay() + 1) / 7);
|
533
530
|
}
|
534
531
|
year(date) {
|
535
532
|
return this.toJalali(date).year;
|
@@ -549,43 +546,41 @@ class JalaliCalendar {
|
|
549
546
|
case 'hour':
|
550
547
|
value += 3600000 * amount;
|
551
548
|
break;
|
552
|
-
case 'month':
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
}
|
549
|
+
case 'month': {
|
550
|
+
const v = new Date(value);
|
551
|
+
let jd = this.dayOfMonth(date);
|
552
|
+
let jm = this.monthOfYear(date);
|
553
|
+
let jy = this.year(date);
|
554
|
+
const nm = jm + amount;
|
555
|
+
const ny = nm % 12 ? Math.floor(nm / 12) : 0;
|
556
|
+
jy += ny;
|
557
|
+
jm = nm - ny * 12;
|
558
|
+
const vv = this.toGregorian(jy, jm, jd);
|
559
|
+
v.setFullYear(vv.getFullYear());
|
560
|
+
v.setMonth(vv.getMonth());
|
561
|
+
v.setDate(vv.getDate());
|
562
|
+
value = v.valueOf();
|
563
|
+
break;
|
564
|
+
}
|
569
565
|
case 'week':
|
570
566
|
value += 7 * 86400000 * amount;
|
571
567
|
break;
|
572
|
-
case 'year':
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
}
|
568
|
+
case 'year': {
|
569
|
+
// const v = new Date(value);
|
570
|
+
// v.setFullYear(v.getFullYear() + amount);
|
571
|
+
// value = v.valueOf();
|
572
|
+
// break
|
573
|
+
const v = new Date(value);
|
574
|
+
let jd = this.dayOfMonth(date);
|
575
|
+
let jm = this.monthOfYear(date);
|
576
|
+
let jy = this.year(date);
|
577
|
+
const vv = this.toGregorian(jy + amount, jm, jd);
|
578
|
+
v.setFullYear(vv.getFullYear());
|
579
|
+
v.setMonth(vv.getMonth());
|
580
|
+
v.setDate(vv.getDate());
|
581
|
+
value = v.valueOf();
|
582
|
+
break;
|
583
|
+
}
|
589
584
|
case 'day':
|
590
585
|
default:
|
591
586
|
value += 86400000 * amount;
|
@@ -610,13 +605,13 @@ class JalaliCalendar {
|
|
610
605
|
const gDate = this.toGregorian(jDate.year, jDate.month, value);
|
611
606
|
clone.setDate(gDate.getDate());
|
612
607
|
break;
|
613
|
-
case
|
608
|
+
case 'week':
|
614
609
|
break;
|
615
|
-
case
|
610
|
+
case 'month':
|
616
611
|
const gDate2 = this.toGregorian(jDate.year, value, jDate.day);
|
617
612
|
clone.setMonth(gDate2.getMonth());
|
618
613
|
break;
|
619
|
-
case
|
614
|
+
case 'year':
|
620
615
|
const gDate3 = this.toGregorian(value, jDate.month, jDate.day);
|
621
616
|
clone.setFullYear(gDate3.getFullYear());
|
622
617
|
break;
|
@@ -639,21 +634,21 @@ class JalaliCalendar {
|
|
639
634
|
case 'day':
|
640
635
|
clone.setHours(0, 0, 0, 0);
|
641
636
|
return new AXDateTime(clone, this.name());
|
642
|
-
case
|
643
|
-
return new AXDateTime(clone, this.name())
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
637
|
+
case 'week':
|
638
|
+
return new AXDateTime(clone, this.name())
|
639
|
+
.add('day', -this.dayOfWeek(clone) + 1)
|
640
|
+
.startOf('day');
|
641
|
+
case 'month': {
|
642
|
+
const jy = this.year(date);
|
643
|
+
const jm = this.monthOfYear(date);
|
644
|
+
const gDate = this.toGregorian(jy, jm, 1);
|
645
|
+
return new AXDateTime(gDate, this.name()).startOf('day');
|
646
|
+
}
|
647
|
+
case 'year': {
|
648
|
+
const jy = this.year(date);
|
649
|
+
const gDate = this.toGregorian(jy, 1, 1);
|
650
|
+
return new AXDateTime(gDate, this.name()).startOf('day');
|
651
|
+
}
|
657
652
|
}
|
658
653
|
}
|
659
654
|
endOf(date, unit) {
|
@@ -672,19 +667,17 @@ class JalaliCalendar {
|
|
672
667
|
case 'day':
|
673
668
|
clone.setHours(23, 59, 59, 999);
|
674
669
|
return new AXDateTime(clone, this.name());
|
675
|
-
case 'week':
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
}
|
687
|
-
case "year":
|
670
|
+
case 'week': {
|
671
|
+
return this.startOf(date, 'week').add('day', 6).endOf('day');
|
672
|
+
}
|
673
|
+
case 'month': {
|
674
|
+
const jy = this.year(date);
|
675
|
+
const jm = this.monthOfYear(date);
|
676
|
+
const jd = this.monthLength(jy, jm);
|
677
|
+
const gDate = this.toGregorian(jy, jm, jd);
|
678
|
+
return new AXDateTime(gDate, this.name()).endOf('day');
|
679
|
+
}
|
680
|
+
case 'year':
|
688
681
|
let jy = this.year(date);
|
689
682
|
const gDate = this.toGregorian(jy, 12, this.monthLength(jy, 12));
|
690
683
|
return new AXDateTime(gDate, this.name()).endOf('day');
|
@@ -702,29 +695,27 @@ class JalaliCalendar {
|
|
702
695
|
};
|
703
696
|
}
|
704
697
|
/*
|
705
|
-
|
706
|
-
|
698
|
+
Converts a Jalaali date to Gregorian.
|
699
|
+
*/
|
707
700
|
toGregorian(jy, jm, jd) {
|
708
701
|
const g = this.d2g(this.j2d(jy, jm, jd));
|
709
702
|
return new Date(g.gy, g.gm - 1, g.gd);
|
710
703
|
}
|
711
704
|
/*
|
712
|
-
|
713
|
-
|
705
|
+
Checks whether a Jalaali date is valid or not.
|
706
|
+
*/
|
714
707
|
isValid(jy, jm, jd) {
|
715
|
-
return jy >= -61 && jy <= 3177 &&
|
716
|
-
jm >= 1 && jm <= 12 &&
|
717
|
-
jd >= 1 && jd <= this.monthLength(jy, jm);
|
708
|
+
return (jy >= -61 && jy <= 3177 && jm >= 1 && jm <= 12 && jd >= 1 && jd <= this.monthLength(jy, jm));
|
718
709
|
}
|
719
710
|
/*
|
720
|
-
|
721
|
-
|
711
|
+
Is this a leap year or not?
|
712
|
+
*/
|
722
713
|
isLeapYear(jy) {
|
723
714
|
return this.jalCal(jy).leap === 0;
|
724
715
|
}
|
725
716
|
/*
|
726
|
-
|
727
|
-
|
717
|
+
Number of days in a given month in a Jalaali year.
|
718
|
+
*/
|
728
719
|
monthLength(jy, jm) {
|
729
720
|
if (jm <= 6)
|
730
721
|
return 31;
|
@@ -736,8 +727,9 @@ class JalaliCalendar {
|
|
736
727
|
}
|
737
728
|
jalCal(jy) {
|
738
729
|
// Jalaali years starting the 33-year rule.
|
739
|
-
let breaks = [
|
740
|
-
1635, 2060, 2097, 2192, 2262, 2324,
|
730
|
+
let breaks = [
|
731
|
+
-61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210, 1635, 2060, 2097, 2192, 2262, 2324,
|
732
|
+
2394, 2456, 3178,
|
741
733
|
], bl = breaks.length, gy = jy + 621, leapJ = -14, jp = breaks[0], jm, jump, leap, leapG, march, n, i;
|
742
734
|
if (jy < jp || jy >= breaks[bl - 1])
|
743
735
|
throw new Error('Invalid Jalaali year ' + jy);
|
@@ -770,31 +762,31 @@ class JalaliCalendar {
|
|
770
762
|
return {
|
771
763
|
leap: leap,
|
772
764
|
gy: gy,
|
773
|
-
march: march
|
765
|
+
march: march,
|
774
766
|
};
|
775
767
|
}
|
776
768
|
/*
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
769
|
+
Converts a date of the Jalaali calendar to the Julian Day number.
|
770
|
+
@param jy Jalaali year (1 to 3100)
|
771
|
+
@param jm Jalaali month (1 to 12)
|
772
|
+
@param jd Jalaali day (1 to 29/31)
|
773
|
+
@return Julian Day number
|
774
|
+
*/
|
783
775
|
j2d(jy, jm, jd) {
|
784
776
|
let r = this.jalCal(jy);
|
785
777
|
return this.g2d(r.gy, 3, r.march) + (jm - 1) * 31 - this.div(jm, 7) * (jm - 7) + jd - 1;
|
786
778
|
}
|
787
779
|
/*
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
780
|
+
Converts the Julian Day number to a date in the Jalaali calendar.
|
781
|
+
@param jdn Julian Day number
|
782
|
+
@return
|
783
|
+
jy: Jalaali year (1 to 3100)
|
784
|
+
jm: Jalaali month (1 to 12)
|
785
|
+
jd: Jalaali day (1 to 29/31)
|
786
|
+
*/
|
795
787
|
d2j(jdn) {
|
796
|
-
let gy = this.d2g(jdn).gy // Calculate Gregorian year (gy).
|
797
|
-
|
788
|
+
let gy = this.d2g(jdn).gy, // Calculate Gregorian year (gy).
|
789
|
+
jy = gy - 621, r = this.jalCal(jy), jdn1f = this.g2d(gy, 3, r.march), jd, jm, k;
|
798
790
|
// Find number of days that passed since 1 Farvardin.
|
799
791
|
k = jdn - jdn1f;
|
800
792
|
if (k >= 0) {
|
@@ -805,7 +797,7 @@ class JalaliCalendar {
|
|
805
797
|
return {
|
806
798
|
jy: jy,
|
807
799
|
jm: jm,
|
808
|
-
jd: jd
|
800
|
+
jd: jd,
|
809
801
|
};
|
810
802
|
}
|
811
803
|
else {
|
@@ -825,13 +817,14 @@ class JalaliCalendar {
|
|
825
817
|
return {
|
826
818
|
jy: jy,
|
827
819
|
jm: jm,
|
828
|
-
jd: jd
|
820
|
+
jd: jd,
|
829
821
|
};
|
830
822
|
}
|
831
823
|
g2d(gy, gm, gd) {
|
832
|
-
let d = this.div((gy + this.div(gm - 8, 6) + 100100) * 1461, 4)
|
833
|
-
|
834
|
-
|
824
|
+
let d = this.div((gy + this.div(gm - 8, 6) + 100100) * 1461, 4) +
|
825
|
+
this.div(153 * this.mod(gm + 9, 12) + 2, 5) +
|
826
|
+
gd -
|
827
|
+
34840408;
|
835
828
|
d = d - this.div(this.div(gy + 100100 + this.div(gm - 8, 6), 100) * 3, 4) + 752;
|
836
829
|
return d;
|
837
830
|
}
|
@@ -846,17 +839,17 @@ class JalaliCalendar {
|
|
846
839
|
return {
|
847
840
|
gy: gy,
|
848
841
|
gm: gm,
|
849
|
-
gd: gd
|
842
|
+
gd: gd,
|
850
843
|
};
|
851
844
|
}
|
852
845
|
/*
|
853
|
-
|
854
|
-
|
846
|
+
Utility helper functions.
|
847
|
+
*/
|
855
848
|
div(a, b) {
|
856
|
-
return
|
849
|
+
return a / b;
|
857
850
|
}
|
858
851
|
mod(a, b) {
|
859
|
-
return a -
|
852
|
+
return a - (a / b) * b;
|
860
853
|
}
|
861
854
|
}
|
862
855
|
|
@@ -879,11 +872,11 @@ class AXDateTimeModule {
|
|
879
872
|
}
|
880
873
|
});
|
881
874
|
}
|
882
|
-
static
|
883
|
-
static
|
884
|
-
static
|
875
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
876
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimeModule, declarations: [AXDateTimePipe], exports: [AXDateTimePipe] }); }
|
877
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimeModule }); }
|
885
878
|
}
|
886
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.
|
879
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: AXDateTimeModule, decorators: [{
|
887
880
|
type: NgModule,
|
888
881
|
args: [{
|
889
882
|
imports: [],
|