@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.
Files changed (178) hide show
  1. package/README.md +3 -20
  2. package/config/README.md +3 -0
  3. package/config/index.d.ts +2 -5
  4. package/config/lib/configs.service.d.ts +5 -0
  5. package/dateTime/README.md +3 -0
  6. package/dateTime/index.d.ts +5 -5
  7. package/dateTime/{src → lib}/jalali.calendar.d.ts +1 -1
  8. package/esm2022/acorex-core.mjs +2 -2
  9. package/esm2022/config/acorex-core-config.mjs +2 -2
  10. package/esm2022/config/index.mjs +3 -0
  11. package/esm2022/config/lib/configs.mjs +24 -0
  12. package/esm2022/config/lib/configs.service.mjs +11 -0
  13. package/esm2022/dateTime/acorex-core-dateTime.mjs +2 -2
  14. package/esm2022/dateTime/index.mjs +6 -0
  15. package/esm2022/dateTime/lib/datetime.class.mjs +288 -0
  16. package/esm2022/dateTime/lib/datetime.module.mjs +39 -0
  17. package/esm2022/dateTime/lib/datetime.pipe.mjs +26 -0
  18. package/esm2022/dateTime/lib/georgian.calendar.mjs +189 -0
  19. package/esm2022/dateTime/lib/jalali.calendar.mjs +355 -0
  20. package/esm2022/events/acorex-core-events.mjs +2 -2
  21. package/esm2022/events/index.mjs +2 -0
  22. package/esm2022/events/lib/event.service.mjs +36 -0
  23. package/esm2022/file/acorex-core-file.mjs +2 -2
  24. package/esm2022/file/index.mjs +5 -0
  25. package/esm2022/file/lib/file-download-ref.class.mjs +12 -0
  26. package/esm2022/file/lib/file-download-result.class.mjs +46 -0
  27. package/esm2022/file/lib/file-upload-ref.class.mjs +12 -0
  28. package/esm2022/file/lib/file.service.mjs +102 -0
  29. package/esm2022/http/acorex-core-http.mjs +2 -2
  30. package/esm2022/http/index.mjs +7 -0
  31. package/esm2022/http/lib/http-error.class.mjs +2 -0
  32. package/esm2022/http/lib/http-events.interceptor.mjs +3 -0
  33. package/esm2022/http/lib/http-request.class.mjs +2 -0
  34. package/esm2022/http/lib/http-result.class.mjs +21 -0
  35. package/esm2022/http/lib/http.module.mjs +29 -0
  36. package/esm2022/http/lib/http.service.mjs +148 -0
  37. package/esm2022/image/acorex-core-image.mjs +2 -2
  38. package/esm2022/image/index.mjs +2 -0
  39. package/esm2022/image/lib/image.service.mjs +43 -0
  40. package/esm2022/index.mjs +2 -0
  41. package/esm2022/pipes/acorex-core-pipes.mjs +2 -2
  42. package/esm2022/pipes/index.mjs +3 -0
  43. package/esm2022/pipes/lib/pipes.module.mjs +19 -0
  44. package/esm2022/pipes/lib/safe.pipe.mjs +31 -0
  45. package/esm2022/platform/acorex-core-platform.mjs +2 -2
  46. package/esm2022/platform/index.mjs +2 -0
  47. package/esm2022/platform/lib/platform.service.mjs +155 -0
  48. package/esm2022/translation/acorex-core-translation.mjs +2 -2
  49. package/esm2022/translation/index.mjs +4 -0
  50. package/esm2022/translation/lib/translation.module.mjs +18 -0
  51. package/esm2022/translation/lib/translator.mjs +43 -0
  52. package/esm2022/translation/lib/translator.pipe.mjs +15 -0
  53. package/esm2022/utils/acorex-core-utils.mjs +2 -2
  54. package/esm2022/utils/index.mjs +6 -0
  55. package/esm2022/utils/lib/color-util.mjs +115 -0
  56. package/esm2022/utils/lib/drawing-util.mjs +29 -0
  57. package/esm2022/utils/lib/html-util.mjs +16 -0
  58. package/esm2022/utils/lib/object-util.mjs +39 -0
  59. package/esm2022/utils/lib/string-util.mjs +19 -0
  60. package/events/README.md +3 -0
  61. package/events/index.d.ts +1 -5
  62. package/fesm2022/acorex-core-config.mjs +14 -3
  63. package/fesm2022/acorex-core-config.mjs.map +1 -1
  64. package/fesm2022/acorex-core-dateTime.mjs +171 -178
  65. package/fesm2022/acorex-core-dateTime.mjs.map +1 -1
  66. package/fesm2022/acorex-core-events.mjs +6 -4
  67. package/fesm2022/acorex-core-events.mjs.map +1 -1
  68. package/fesm2022/acorex-core-file.mjs +19 -23
  69. package/fesm2022/acorex-core-file.mjs.map +1 -1
  70. package/fesm2022/acorex-core-http.mjs +10 -17
  71. package/fesm2022/acorex-core-http.mjs.map +1 -1
  72. package/fesm2022/acorex-core-image.mjs +3 -3
  73. package/fesm2022/acorex-core-image.mjs.map +1 -1
  74. package/fesm2022/acorex-core-pipes.mjs +8 -9
  75. package/fesm2022/acorex-core-pipes.mjs.map +1 -1
  76. package/fesm2022/acorex-core-platform.mjs +6 -8
  77. package/fesm2022/acorex-core-platform.mjs.map +1 -1
  78. package/fesm2022/acorex-core-translation.mjs +13 -13
  79. package/fesm2022/acorex-core-translation.mjs.map +1 -1
  80. package/fesm2022/acorex-core-utils.mjs +87 -87
  81. package/fesm2022/acorex-core-utils.mjs.map +1 -1
  82. package/fesm2022/acorex-core.mjs +1 -6
  83. package/fesm2022/acorex-core.mjs.map +1 -1
  84. package/file/README.md +3 -0
  85. package/file/index.d.ts +4 -5
  86. package/http/README.md +3 -0
  87. package/http/index.d.ts +6 -5
  88. package/image/README.md +3 -0
  89. package/image/index.d.ts +1 -5
  90. package/index.d.ts +2 -5
  91. package/package.json +13 -11
  92. package/pipes/README.md +3 -0
  93. package/pipes/index.d.ts +2 -5
  94. package/platform/README.md +3 -0
  95. package/platform/index.d.ts +1 -5
  96. package/translation/README.md +3 -0
  97. package/translation/index.d.ts +3 -5
  98. package/utils/README.md +3 -0
  99. package/utils/index.d.ts +5 -5
  100. package/config/public-api.d.ts +0 -1
  101. package/dateTime/public-api.d.ts +0 -5
  102. package/esm2022/config/public-api.mjs +0 -2
  103. package/esm2022/config/src/configs.mjs +0 -25
  104. package/esm2022/dateTime/public-api.mjs +0 -6
  105. package/esm2022/dateTime/src/datetime.class.mjs +0 -295
  106. package/esm2022/dateTime/src/datetime.module.mjs +0 -40
  107. package/esm2022/dateTime/src/datetime.pipe.mjs +0 -27
  108. package/esm2022/dateTime/src/georgian.calendar.mjs +0 -187
  109. package/esm2022/dateTime/src/jalali.calendar.mjs +0 -357
  110. package/esm2022/events/public-api.mjs +0 -2
  111. package/esm2022/events/src/event.service.mjs +0 -35
  112. package/esm2022/file/public-api.mjs +0 -5
  113. package/esm2022/file/src/file-download-ref.class.mjs +0 -13
  114. package/esm2022/file/src/file-download-result.class.mjs +0 -47
  115. package/esm2022/file/src/file-upload-ref.class.mjs +0 -13
  116. package/esm2022/file/src/file.service.mjs +0 -103
  117. package/esm2022/http/public-api.mjs +0 -6
  118. package/esm2022/http/src/http-error.class.mjs +0 -2
  119. package/esm2022/http/src/http-events.interceptor.mjs +0 -3
  120. package/esm2022/http/src/http-request.class.mjs +0 -2
  121. package/esm2022/http/src/http-result.class.mjs +0 -25
  122. package/esm2022/http/src/http.module.mjs +0 -30
  123. package/esm2022/http/src/http.service.mjs +0 -152
  124. package/esm2022/image/public-api.mjs +0 -2
  125. package/esm2022/image/src/image.service.mjs +0 -44
  126. package/esm2022/pipes/public-api.mjs +0 -3
  127. package/esm2022/pipes/src/pipes.module.mjs +0 -20
  128. package/esm2022/pipes/src/safe.pipe.mjs +0 -32
  129. package/esm2022/platform/public-api.mjs +0 -2
  130. package/esm2022/platform/src/platform.service.mjs +0 -158
  131. package/esm2022/public-api.mjs +0 -5
  132. package/esm2022/translation/public-api.mjs +0 -4
  133. package/esm2022/translation/src/translation.module.mjs +0 -19
  134. package/esm2022/translation/src/translator.mjs +0 -44
  135. package/esm2022/translation/src/translator.pipe.mjs +0 -16
  136. package/esm2022/utils/public-api.mjs +0 -6
  137. package/esm2022/utils/src/color-util.mjs +0 -115
  138. package/esm2022/utils/src/drawing-util.mjs +0 -29
  139. package/esm2022/utils/src/html-util.mjs +0 -16
  140. package/esm2022/utils/src/object-util.mjs +0 -39
  141. package/esm2022/utils/src/string-util.mjs +0 -19
  142. package/events/public-api.d.ts +0 -1
  143. package/file/public-api.d.ts +0 -4
  144. package/http/public-api.d.ts +0 -5
  145. package/image/public-api.d.ts +0 -1
  146. package/pipes/public-api.d.ts +0 -2
  147. package/platform/public-api.d.ts +0 -1
  148. package/public-api.d.ts +0 -1
  149. package/translation/public-api.d.ts +0 -3
  150. package/utils/public-api.d.ts +0 -5
  151. /package/config/{src → lib}/configs.d.ts +0 -0
  152. /package/dateTime/{src → lib}/datetime.class.d.ts +0 -0
  153. /package/dateTime/{src → lib}/datetime.module.d.ts +0 -0
  154. /package/dateTime/{src → lib}/datetime.pipe.d.ts +0 -0
  155. /package/dateTime/{src → lib}/georgian.calendar.d.ts +0 -0
  156. /package/events/{src → lib}/event.service.d.ts +0 -0
  157. /package/file/{src → lib}/file-download-ref.class.d.ts +0 -0
  158. /package/file/{src → lib}/file-download-result.class.d.ts +0 -0
  159. /package/file/{src → lib}/file-upload-ref.class.d.ts +0 -0
  160. /package/file/{src → lib}/file.service.d.ts +0 -0
  161. /package/http/{src → lib}/http-error.class.d.ts +0 -0
  162. /package/http/{src → lib}/http-events.interceptor.d.ts +0 -0
  163. /package/http/{src → lib}/http-request.class.d.ts +0 -0
  164. /package/http/{src → lib}/http-result.class.d.ts +0 -0
  165. /package/http/{src → lib}/http.module.d.ts +0 -0
  166. /package/http/{src → lib}/http.service.d.ts +0 -0
  167. /package/image/{src → lib}/image.service.d.ts +0 -0
  168. /package/pipes/{src → lib}/pipes.module.d.ts +0 -0
  169. /package/pipes/{src → lib}/safe.pipe.d.ts +0 -0
  170. /package/platform/{src → lib}/platform.service.d.ts +0 -0
  171. /package/translation/{src → lib}/translation.module.d.ts +0 -0
  172. /package/translation/{src → lib}/translator.d.ts +0 -0
  173. /package/translation/{src → lib}/translator.pipe.d.ts +0 -0
  174. /package/utils/{src → lib}/color-util.d.ts +0 -0
  175. /package/utils/{src → lib}/drawing-util.d.ts +0 -0
  176. /package/utils/{src → lib}/html-util.d.ts +0 -0
  177. /package/utils/{src → lib}/object-util.d.ts +0 -0
  178. /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("|"), "gi");
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 ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.3", ngImport: i0, type: AXDateTimePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
314
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.1.3", ngImport: i0, type: AXDateTimePipe, name: "axDate" });
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.3", ngImport: i0, type: AXDateTimePipe, decorators: [{
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
- monthNames = [
323
- "January", "February", "March",
324
- "April", "May", "June", "July",
325
- "August", "September", "October",
326
- "November", "December"
327
- ];
328
- monthShortNames = [
329
- "Jan", "Feb", "Mar",
330
- "Apr", "May", "Jun", "Jul",
331
- "Aug", "Sep", "Oct",
332
- "Nov", "Dec"
333
- ];
334
- dayNames = [
335
- "Sunday", "Monday", "Tuesday", "Wednesday",
336
- "Thursday", "Friday", "Saturday"
337
- ];
338
- dayShortNames = [
339
- "Sun", "Mon", "Tue", "Wed",
340
- "Thu", "Fri", "Sat"
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
- monthNames = ("فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند").split("_");
509
- monthShortNames = ("فروردین_اردیبهشت_خرداد_تیر_مرداد_شهریور_مهر_آبان_آذر_دی_بهمن_اسفند").split("_");
510
- dayNames = ("شنبه_یکشنبه_دوشنبه_سه شنبه_چهارشنبه_پنج شنبه_جمعه").split("_");
511
- dayShortNames = _ی_د_س_چ_پ_ج".split("_");
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 ? ((j.month - 1) * 31) : ((6 * 31) + (j.month - 7) * 30)) + j.day;
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((((date.getTime() - firstDay.date.getTime()) / 86400000) + firstDay.date.getDay() + 1) / 7);
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
- const v = new Date(value);
555
- let jd = this.dayOfMonth(date);
556
- let jm = this.monthOfYear(date);
557
- let jy = this.year(date);
558
- const nm = (jm + amount);
559
- const ny = (nm % 12) ? Math.floor(nm / 12) : 0;
560
- jy += ny;
561
- jm = nm - (ny * 12);
562
- const vv = this.toGregorian(jy, jm, jd);
563
- v.setFullYear(vv.getFullYear());
564
- v.setMonth(vv.getMonth());
565
- v.setDate(vv.getDate());
566
- value = v.valueOf();
567
- break;
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
- // const v = new Date(value);
575
- // v.setFullYear(v.getFullYear() + amount);
576
- // value = v.valueOf();
577
- // break
578
- const v = new Date(value);
579
- let jd = this.dayOfMonth(date);
580
- let jm = this.monthOfYear(date);
581
- let jy = this.year(date);
582
- const vv = this.toGregorian(jy + amount, jm, jd);
583
- v.setFullYear(vv.getFullYear());
584
- v.setMonth(vv.getMonth());
585
- v.setDate(vv.getDate());
586
- value = v.valueOf();
587
- break;
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 "week":
608
+ case 'week':
614
609
  break;
615
- case "month":
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 "year":
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 "week":
643
- return new AXDateTime(clone, this.name()).add('day', -this.dayOfWeek(clone) + 1).startOf('day');
644
- case "month":
645
- {
646
- const jy = this.year(date);
647
- const jm = this.monthOfYear(date);
648
- const gDate = this.toGregorian(jy, jm, 1);
649
- return new AXDateTime(gDate, this.name()).startOf('day');
650
- }
651
- case "year":
652
- {
653
- const jy = this.year(date);
654
- const gDate = this.toGregorian(jy, 1, 1);
655
- return new AXDateTime(gDate, this.name()).startOf('day');
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
- return this.startOf(date, 'week').add('day', 6).endOf('day');
678
- }
679
- case 'month':
680
- {
681
- const jy = this.year(date);
682
- const jm = this.monthOfYear(date);
683
- const jd = this.monthLength(jy, jm);
684
- const gDate = this.toGregorian(jy, jm, jd);
685
- return new AXDateTime(gDate, this.name()).endOf('day');
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
- Converts a Jalaali date to Gregorian.
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
- Checks whether a Jalaali date is valid or not.
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
- Is this a leap year or not?
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
- Number of days in a given month in a Jalaali year.
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 = [-61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210,
740
- 1635, 2060, 2097, 2192, 2262, 2324, 2394, 2456, 3178
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
- Converts a date of the Jalaali calendar to the Julian Day number.
778
- @param jy Jalaali year (1 to 3100)
779
- @param jm Jalaali month (1 to 12)
780
- @param jd Jalaali day (1 to 29/31)
781
- @return Julian Day number
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
- Converts the Julian Day number to a date in the Jalaali calendar.
789
- @param jdn Julian Day number
790
- @return
791
- jy: Jalaali year (1 to 3100)
792
- jm: Jalaali month (1 to 12)
793
- jd: Jalaali day (1 to 29/31)
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
- , jy = gy - 621, r = this.jalCal(jy), jdn1f = this.g2d(gy, 3, r.march), jd, jm, k;
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
- + this.div(153 * this.mod(gm + 9, 12) + 2, 5)
834
- + gd - 34840408;
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
- Utility helper functions.
854
- */
846
+ Utility helper functions.
847
+ */
855
848
  div(a, b) {
856
- return ~~(a / b);
849
+ return a / b;
857
850
  }
858
851
  mod(a, b) {
859
- return a - ~~(a / b) * b;
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 ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.3", ngImport: i0, type: AXDateTimeModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
883
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.1.3", ngImport: i0, type: AXDateTimeModule, declarations: [AXDateTimePipe], exports: [AXDateTimePipe] });
884
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.1.3", ngImport: i0, type: AXDateTimeModule });
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.3", ngImport: i0, type: AXDateTimeModule, decorators: [{
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: [],