@ajf/calendars 15.3.14 → 16.0.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.
@@ -1,732 +0,0 @@
1
- import { AjfCalendarService } from '@ajf/core/calendar';
2
- import * as i0 from '@angular/core';
3
- import { Injectable, Pipe, NgModule } from '@angular/core';
4
- import { getISODay, startOfISOWeek, endOfISOWeek, addWeeks, subWeeks, setISODay, startOfWeek, addDays, addYears } from 'date-fns';
5
-
6
- /**
7
- * @license
8
- * Copyright (C) Gnucoop soc. coop.
9
- *
10
- * This file is part of the Advanced JSON forms (ajf).
11
- *
12
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
13
- * modify it under the terms of the GNU Affero General Public License as
14
- * published by the Free Software Foundation, either version 3 of the License,
15
- * or (at your option) any later version.
16
- *
17
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
20
- * General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU Affero General Public License
23
- * along with Advanced JSON forms (ajf).
24
- * If not, see http://www.gnu.org/licenses/.
25
- *
26
- */
27
- const JD_EPOCH_OFFSET_AMETE_ALEM = -285019; // ዓ/ዓ
28
- const JD_EPOCH_OFFSET_AMETE_MIHRET = 1723856; // ዓ/ም
29
- const JD_EPOCH_OFFSET_GREGORIAN = 1721426;
30
- const JD_EPOCH_OFFSET_UNSET = -1;
31
- let JDN_OFFSET = JD_EPOCH_OFFSET_UNSET;
32
- const GREGORIAN_NUMBER_OF_MONTHS = 12;
33
- const monthDays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
34
- function quotient(i, j) {
35
- return Math.floor(i / j);
36
- }
37
- function isGregorianLeap(year) {
38
- return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
39
- }
40
- function setEra(era) {
41
- if (era === JD_EPOCH_OFFSET_AMETE_ALEM || era === JD_EPOCH_OFFSET_AMETE_MIHRET) {
42
- JDN_OFFSET = era;
43
- }
44
- else {
45
- throw new Error(`Unknown Era: ${era}`);
46
- }
47
- }
48
- function isEraSet() {
49
- return JD_EPOCH_OFFSET_UNSET !== JDN_OFFSET;
50
- }
51
- function unsetEra() {
52
- JDN_OFFSET = JD_EPOCH_OFFSET_UNSET;
53
- }
54
- function guessEraFromJDN(jdn) {
55
- return jdn >= JD_EPOCH_OFFSET_AMETE_MIHRET + 365
56
- ? JD_EPOCH_OFFSET_AMETE_MIHRET
57
- : JD_EPOCH_OFFSET_AMETE_ALEM;
58
- }
59
- function ethiopicToJDN(day, month, year) {
60
- const ERA = isEraSet() ? JDN_OFFSET : JD_EPOCH_OFFSET_AMETE_MIHRET;
61
- const jdn = ERA + 365 + 365 * (year - 1) + quotient(year, 4) + 30 * month + day - 31;
62
- return jdn;
63
- }
64
- function jdnToEthiopic(jdn) {
65
- const ERA = isEraSet() ? JDN_OFFSET : guessEraFromJDN(jdn);
66
- const r = (jdn - ERA) % 1461;
67
- const n = (r % 365) + 365 * quotient(r, 1460);
68
- const year = 4 * quotient(jdn - ERA, 1461) + quotient(r, 365) - quotient(r, 1460);
69
- const month = quotient(n, 30) + 1;
70
- const day = (n % 30) + 1;
71
- return [year, month, day];
72
- }
73
- function gregorianToJDN(day, month, year) {
74
- const s = quotient(year, 4) -
75
- quotient(year - 1, 4) -
76
- quotient(year, 100) +
77
- quotient(year - 1, 100) +
78
- quotient(year, 400) -
79
- quotient(year - 1, 400);
80
- const t = quotient(14 - month, 12);
81
- const n = 31 * t * (month - 1) +
82
- (1 - t) * (59 + s + 30 * (month - 3) + quotient(3 * month - 7, 5)) +
83
- day -
84
- 1;
85
- const j = JD_EPOCH_OFFSET_GREGORIAN +
86
- 365 * (year - 1) +
87
- quotient(year - 1, 4) -
88
- quotient(year - 1, 100) +
89
- quotient(year - 1, 400) +
90
- n;
91
- return j;
92
- }
93
- function jdnToGregorian(jdn) {
94
- const r2000 = (jdn - JD_EPOCH_OFFSET_GREGORIAN) % 730485;
95
- const r400 = (jdn - JD_EPOCH_OFFSET_GREGORIAN) % 146097;
96
- const r100 = r400 % 36524;
97
- const r4 = r100 % 1461;
98
- let n = (r4 % 365) + 365 * quotient(r4, 1460);
99
- const s = quotient(r4, 1095);
100
- const aprime = 400 * quotient(jdn - JD_EPOCH_OFFSET_GREGORIAN, 146097) +
101
- 100 * quotient(r400, 36524) +
102
- 4 * quotient(r100, 1461) +
103
- quotient(r4, 365) -
104
- quotient(r4, 1460) -
105
- quotient(r2000, 730484);
106
- const year = aprime + 1;
107
- const t = quotient(364 + s - n, 306);
108
- let month = t * (quotient(n, 31) + 1) + (1 - t) * (quotient(5 * (n - s) + 13, 153) + 1);
109
- n += 1 - quotient(r2000, 730484);
110
- let day = n;
111
- if (r100 === 0 && n === 0 && r400 !== 0) {
112
- month = 12;
113
- day = 31;
114
- }
115
- else {
116
- monthDays[2] = isGregorianLeap(year) ? 29 : 28;
117
- for (let i = 1; i <= GREGORIAN_NUMBER_OF_MONTHS; i += 1) {
118
- if (n <= monthDays[i]) {
119
- day = n;
120
- break;
121
- }
122
- n -= monthDays[i];
123
- }
124
- }
125
- return [year, month, day];
126
- }
127
- function gregorianToEthiopic(day, month, year) {
128
- const jdn = gregorianToJDN(day, month, year);
129
- return jdnToEthiopic(jdn);
130
- }
131
- function ethioipicToGreg(day, month, year) {
132
- const jdn = ethiopicToJDN(day, month, year);
133
- return jdnToGregorian(jdn);
134
- }
135
- function ethioipicToGregorian(day, month, year, era) {
136
- setEra(era);
137
- const result = ethioipicToGreg(day, month, year);
138
- unsetEra();
139
- return result;
140
- }
141
- /** API * */
142
- /** ethiopian to gregorian */
143
- function toGC(dateArray) {
144
- const [y, m, d] = dateArray;
145
- let era = dateArray.length === 4 ? dateArray[3] : JD_EPOCH_OFFSET_AMETE_MIHRET;
146
- if (d < 0 || d > 30 || m < 0 || m > 13) {
147
- throw new Error('Invalid Ethiopian Date');
148
- }
149
- return ethioipicToGregorian(d, m, y, era);
150
- }
151
- /** gregorian to ethiopian */
152
- function toEC(dateArray) {
153
- const [y, m, d] = dateArray;
154
- if (d < 0 || d > 31 || m < 0 || m > 12) {
155
- throw new Error('Invalid Gregorian Date');
156
- }
157
- return gregorianToEthiopic(d, m, y);
158
- }
159
-
160
- /**
161
- * @license
162
- * Copyright (C) Gnucoop soc. coop.
163
- *
164
- * This file is part of the Advanced JSON forms (ajf).
165
- *
166
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
167
- * modify it under the terms of the GNU Affero General Public License as
168
- * published by the Free Software Foundation, either version 3 of the License,
169
- * or (at your option) any later version.
170
- *
171
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
172
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
173
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
174
- * General Public License for more details.
175
- *
176
- * You should have received a copy of the GNU Affero General Public License
177
- * along with Advanced JSON forms (ajf).
178
- * If not, see http://www.gnu.org/licenses/.
179
- *
180
- */
181
- const WEEK_NAMES = ['እሑድ', 'ሰኞ', 'ማክሰኞ', 'ረቡዕ', 'ሓሙስ', 'ዓርብ', 'ቅዳሜ'];
182
- const MONTHS_NAMES = [
183
- 'መስከረም',
184
- 'ጥቅምት',
185
- 'ኅዳር',
186
- 'ታኅሣሥ',
187
- 'ጥር',
188
- 'የካቲት',
189
- 'መጋቢት',
190
- 'ሚያዝያ',
191
- 'ግንቦት',
192
- 'ሰኔ',
193
- 'ሐምሌ',
194
- 'ነሐሴ',
195
- 'ጳጉሜን',
196
- ];
197
- const SHORT_MONTHS_NAMES = [
198
- 'መስከ',
199
- 'ጥቅም',
200
- 'ኅዳር',
201
- 'ታኅሣ',
202
- 'ጥር',
203
- 'የካቲ',
204
- 'መጋቢ',
205
- 'ሚያዝ',
206
- 'ግንቦ',
207
- 'ሰኔ',
208
- 'ሐምሌ',
209
- 'ነሐሴ',
210
- 'ጳጉሜ',
211
- ];
212
-
213
- /**
214
- * @license
215
- * Copyright (C) Gnucoop soc. coop.
216
- *
217
- * This file is part of the Advanced JSON forms (ajf).
218
- *
219
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
220
- * modify it under the terms of the GNU Affero General Public License as
221
- * published by the Free Software Foundation, either version 3 of the License,
222
- * or (at your option) any later version.
223
- *
224
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
225
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
226
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
227
- * General Public License for more details.
228
- *
229
- * You should have received a copy of the GNU Affero General Public License
230
- * along with Advanced JSON forms (ajf).
231
- * If not, see http://www.gnu.org/licenses/.
232
- *
233
- */
234
- class EthiopianDate {
235
- /**
236
- * @param val - A numeric year value if the second and third parameters ar provided,
237
- * It should be a date string if not
238
- * @param month A zero-based numeric value for the month (0 for መስከረም, 12 for ጳጉሜን)
239
- * @param day A numeric value equal for the day of the month.
240
- */
241
- constructor(val, month, day) {
242
- this._year = 0;
243
- this._month = 0;
244
- this._date = 0;
245
- this._gc = new Date();
246
- if (val == null && month == null && day == null) {
247
- const ahun = EthiopianDate.gregorianToEthiopian(new Date());
248
- [this._year, this._month, this._date] = [ahun.getFullYear(), ahun.getMonth(), ahun.getDate()];
249
- this._gc = EthiopianDate.ethiopianToGregorian(this._year, this._month, this._date);
250
- }
251
- else if (val != null && month == null && day == null && typeof val !== 'number') {
252
- if (typeof val === 'string') {
253
- const result = EthiopianDate.parse(val);
254
- if (result == null) {
255
- throw new Error('Invalid Argument Exception');
256
- }
257
- [this._year, this._month, this._date] = [
258
- result.getFullYear(),
259
- result.getMonth(),
260
- result.getDate(),
261
- ];
262
- this._gc = EthiopianDate.ethiopianToGregorian(this._year, this._month, this._date);
263
- }
264
- else if (typeof val === 'object' && val instanceof Date) {
265
- const result = EthiopianDate.gregorianToEthiopian(val);
266
- [this._year, this._month, this._date] = [
267
- result.getFullYear(),
268
- result.getMonth(),
269
- result.getDate(),
270
- ];
271
- this._gc = EthiopianDate.ethiopianToGregorian(this._year, this._month, this._date);
272
- }
273
- else {
274
- throw new Error('Invalid Argument Exception');
275
- }
276
- }
277
- else if (val != null && month != null && day != null && typeof val === 'number') {
278
- this._year = val;
279
- this._month = month;
280
- this._date = day;
281
- this._gc = EthiopianDate.ethiopianToGregorian(this._year, this._month, this._date);
282
- }
283
- }
284
- getDate() {
285
- return this._date;
286
- }
287
- getDay() {
288
- return this._gc.getDay();
289
- }
290
- getDayOfWeek() {
291
- const weekDay = this.getGCWeekDay();
292
- return WEEK_NAMES[weekDay];
293
- }
294
- getFullYear() {
295
- return this._year;
296
- }
297
- getGregorianDate() {
298
- return this._gc;
299
- }
300
- getGCWeekDay() {
301
- return this._gc.getDay();
302
- }
303
- getMonth() {
304
- return this._month;
305
- }
306
- getMonthName() {
307
- return this._month >= 0 && this._month < MONTHS_NAMES.length ? MONTHS_NAMES[this._month] : null;
308
- }
309
- getShortMonthName() {
310
- return this._month >= 0 && this._month < SHORT_MONTHS_NAMES.length
311
- ? SHORT_MONTHS_NAMES[this._month]
312
- : null;
313
- }
314
- getHours() {
315
- return 0;
316
- }
317
- getMinutes() {
318
- return 0;
319
- }
320
- getSeconds() {
321
- return 0;
322
- }
323
- getMilliseconds() {
324
- return 0;
325
- }
326
- toString() {
327
- return `${this._year}-${this._month + 1}-${this._date}`;
328
- }
329
- /**
330
- * Converts a Ethiopian date to Gregorian and returns Date instance representing Gregorian Date.
331
- *
332
- * @param val - A numeric year value if the second and third parameters are
333
- * provided, it should be a date string if not
334
- * @param month A zero-based numeric value for the month
335
- * (0 for መስከረም, 12 for ጳጉሜን)
336
- * @param day A numeric value equal for the day of the month.
337
- *
338
- * @api public
339
- */
340
- static ethiopianToGregorian(val, month, day) {
341
- let ec;
342
- if (val != null && month == null && day == null && typeof val !== 'number') {
343
- if (typeof val === 'string') {
344
- const etDate = new EthiopianDate(val);
345
- ec = [etDate.getFullYear(), etDate.getMonth() + 1, etDate.getDate()];
346
- }
347
- else if (typeof val === 'object' && val instanceof EthiopianDate) {
348
- const [y, m, d] = [val.getFullYear(), val.getMonth() + 1, val.getDate()];
349
- ec = [y, m, d];
350
- }
351
- else {
352
- throw new Error('Invalid Argument Exception');
353
- }
354
- }
355
- else if (val != null && month != null && day != null && typeof val === 'number') {
356
- ec = [val, month + 1, day];
357
- }
358
- else {
359
- throw new Error('Invalid Argument Exception');
360
- }
361
- const gc = toGC(ec);
362
- return new Date(gc[0], gc[1] - 1, gc[2]);
363
- }
364
- /**
365
- *
366
- * @param val - A numeric year value if the second and third parameters are
367
- * provided, it should be a date string if not
368
- * @param month A zero-based numeric value for the month
369
- * (0 for January, 11 for December)
370
- * @param day A numeric value equal for the day of the month.
371
- *
372
- * @api public
373
- */
374
- static gregorianToEthiopian(val, month, day) {
375
- let gc;
376
- if (val != null && month == null && day == null && typeof val !== 'number') {
377
- if (typeof val === 'string') {
378
- const gcDate = new Date(val);
379
- gc = [gcDate.getFullYear(), gcDate.getMonth() + 1, gcDate.getDate()];
380
- }
381
- else if (typeof val === 'object' && val instanceof Date) {
382
- const [y, m, d] = [val.getFullYear(), val.getMonth() + 1, val.getDate()];
383
- gc = [y, m, d];
384
- }
385
- else {
386
- throw new Error('Invalid Argument Exception');
387
- }
388
- }
389
- else if (val != null && month != null && day != null && typeof val === 'number') {
390
- gc = [val, month + 1, day];
391
- }
392
- else {
393
- throw new Error('Invalid Argument Exception');
394
- }
395
- const ec = toEC(gc);
396
- return new EthiopianDate(ec[0], ec[1] - 1, ec[2]);
397
- }
398
- /**
399
- * Parse Ethiopian date from string
400
- *
401
- * @param dateString a date string to parse
402
- * @param pattern a parsing pattern
403
- *
404
- * @returns EthiopianDate
405
- */
406
- static parse(dateString) {
407
- if (!dateString) {
408
- return null;
409
- }
410
- const result = dateString.split('-');
411
- if (result.length === 3) {
412
- const [y, m, d] = result;
413
- return new EthiopianDate(parseInt(y, 10), parseInt(m, 10) - 1, parseInt(d, 10));
414
- }
415
- throw new Error(`ParsingError: Can't parse ${dateString}`);
416
- }
417
- }
418
-
419
- /**
420
- * @license
421
- * Copyright (C) Gnucoop soc. coop.
422
- *
423
- * This file is part of the Advanced JSON forms (ajf).
424
- *
425
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
426
- * modify it under the terms of the GNU Affero General Public License as
427
- * published by the Free Software Foundation, either version 3 of the License,
428
- * or (at your option) any later version.
429
- *
430
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
431
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
432
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
433
- * General Public License for more details.
434
- *
435
- * You should have received a copy of the GNU Affero General Public License
436
- * along with Advanced JSON forms (ajf).
437
- * If not, see http://www.gnu.org/licenses/.
438
- *
439
- */
440
- function getMonthDays(month, year) {
441
- if (month < 12) {
442
- return 30;
443
- }
444
- return year % 4 === 3 ? 6 : 5;
445
- }
446
- function getMonthBounds(date) {
447
- const year = date.getFullYear();
448
- const month = date.getMonth();
449
- const start = new EthiopianDate(year, month, 1);
450
- const endDay = getMonthDays(month, year);
451
- const end = new EthiopianDate(year, month, endDay);
452
- return { start, end };
453
- }
454
- class AjfEthiopianCalendarService extends AjfCalendarService {
455
- buildView(params) {
456
- const { viewMode } = params;
457
- const viewDate = EthiopianDate.gregorianToEthiopian(params.viewDate);
458
- switch (viewMode) {
459
- case 'decade':
460
- let curYear = viewDate.getFullYear();
461
- let firstYear = curYear - (curYear % 10) + 1;
462
- let lastYear = firstYear + 11;
463
- return {
464
- header: `${firstYear} - ${lastYear}`,
465
- headerRow: [],
466
- rows: this._ecDecadeCalendarRows(params),
467
- };
468
- case 'year':
469
- return {
470
- header: `${viewDate.getFullYear()}`,
471
- headerRow: [],
472
- rows: this._ecYearCalendarRows(params),
473
- };
474
- case 'month':
475
- const view = super.buildView(params);
476
- return {
477
- header: `${viewDate.getShortMonthName()} ${viewDate.getFullYear()}`,
478
- headerRow: this._ecMonthHeaderRow(params),
479
- rows: view.rows,
480
- };
481
- }
482
- return super.buildView(params);
483
- }
484
- entryLabel(entry) {
485
- const ecDate = EthiopianDate.gregorianToEthiopian(entry.date);
486
- if (entry.type === 'day') {
487
- return `${ecDate.getDate()}`;
488
- }
489
- if (entry.type === 'month') {
490
- return `${ecDate.getMonthName()}`;
491
- }
492
- return `${ecDate.getFullYear()}`;
493
- }
494
- monthBounds(date, isoMode) {
495
- if (!isoMode) {
496
- const ecDate = EthiopianDate.gregorianToEthiopian(date);
497
- const { start, end } = getMonthBounds(ecDate);
498
- return {
499
- start: EthiopianDate.ethiopianToGregorian(start),
500
- end: EthiopianDate.ethiopianToGregorian(end),
501
- };
502
- }
503
- else {
504
- let isoDay = getISODay(date);
505
- const ecDate = EthiopianDate.gregorianToEthiopian(date);
506
- let { start, end } = getMonthBounds(ecDate);
507
- if (ecDate.getMonth() === 12) {
508
- start = EthiopianDate.gregorianToEthiopian(startOfISOWeek(start.getGregorianDate()));
509
- end = EthiopianDate.gregorianToEthiopian(endOfISOWeek(end.getGregorianDate()));
510
- }
511
- else {
512
- date = isoDay < 4 ? endOfISOWeek(date) : startOfISOWeek(date);
513
- const startWeekDay = start.getDay();
514
- const endWeekDay = end.getDay();
515
- if (startWeekDay == 0 || startWeekDay > 4) {
516
- start = EthiopianDate.gregorianToEthiopian(addWeeks(start.getGregorianDate(), 1));
517
- }
518
- if (endWeekDay > 0 && endWeekDay < 4) {
519
- end = EthiopianDate.gregorianToEthiopian(subWeeks(end.getGregorianDate(), 1));
520
- }
521
- }
522
- return {
523
- start: startOfISOWeek(start.getGregorianDate()),
524
- end: endOfISOWeek(end.getGregorianDate()),
525
- };
526
- }
527
- }
528
- nextView(viewDate, viewMode) {
529
- if (viewMode === 'month') {
530
- const ecDate = EthiopianDate.gregorianToEthiopian(viewDate);
531
- let year = ecDate.getFullYear();
532
- let month = ecDate.getMonth();
533
- if (month === 12) {
534
- month = 0;
535
- year += 1;
536
- }
537
- else {
538
- month += 1;
539
- }
540
- return EthiopianDate.ethiopianToGregorian(new EthiopianDate(year, month, 1));
541
- }
542
- return super.nextView(viewDate, viewMode);
543
- }
544
- previousView(viewDate, viewMode) {
545
- if (viewMode === 'month') {
546
- const ecDate = EthiopianDate.gregorianToEthiopian(viewDate);
547
- let year = ecDate.getFullYear();
548
- let month = ecDate.getMonth();
549
- if (month === 0) {
550
- month = 12;
551
- year -= 1;
552
- }
553
- else {
554
- month -= 1;
555
- }
556
- return EthiopianDate.ethiopianToGregorian(new EthiopianDate(year, month, 1));
557
- }
558
- return super.previousView(viewDate, viewMode);
559
- }
560
- _ecMonthHeaderRow(params) {
561
- const { isoMode, viewDate } = params;
562
- let curDate;
563
- if (isoMode) {
564
- curDate = setISODay(startOfWeek(viewDate), 1);
565
- }
566
- else {
567
- curDate = startOfWeek(viewDate);
568
- }
569
- let weekDayNames = [];
570
- for (let i = 0; i < 7; i++) {
571
- const ecDate = EthiopianDate.gregorianToEthiopian(curDate);
572
- weekDayNames.push(ecDate.getDayOfWeek());
573
- curDate = addDays(curDate, 1);
574
- }
575
- return weekDayNames;
576
- }
577
- _ecYearCalendarRows(params) {
578
- const { viewDate, selection } = params;
579
- const year = EthiopianDate.gregorianToEthiopian(viewDate).getFullYear();
580
- let curDate;
581
- let rows = [];
582
- for (let i = 0; i <= 4; i++) {
583
- let row = [];
584
- for (let j = 0; j < 3; j++) {
585
- const curMonth = i * 3 + j;
586
- if (curMonth < 13) {
587
- curDate = new EthiopianDate(year, curMonth, 1);
588
- let date = EthiopianDate.ethiopianToGregorian(curDate);
589
- let newEntry = { type: 'month', date, selected: 'none' };
590
- newEntry.selected = this.isEntrySelected(newEntry, selection);
591
- row.push(newEntry);
592
- }
593
- }
594
- rows.push(row);
595
- }
596
- return rows;
597
- }
598
- _ecDecadeCalendarRows(params) {
599
- const { viewDate, selection } = params;
600
- const ecDate = EthiopianDate.gregorianToEthiopian(viewDate);
601
- let curYear = ecDate.getFullYear();
602
- let firstYear = curYear - (curYear % 10) + 1;
603
- let curDate = EthiopianDate.ethiopianToGregorian(firstYear, 0, 1);
604
- let rows = [];
605
- for (let i = 0; i < 4; i++) {
606
- let row = [];
607
- for (let j = 0; j < 3; j++) {
608
- let date = new Date(curDate);
609
- let newEntry = { type: 'year', date: date, selected: 'none' };
610
- newEntry.selected = this.isEntrySelected(newEntry, selection);
611
- row.push(newEntry);
612
- curDate = addYears(curDate, 1);
613
- }
614
- rows.push(row);
615
- }
616
- return rows;
617
- }
618
- }
619
- AjfEthiopianCalendarService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianCalendarService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
620
- AjfEthiopianCalendarService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianCalendarService, providedIn: 'root' });
621
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianCalendarService, decorators: [{
622
- type: Injectable,
623
- args: [{ providedIn: 'root' }]
624
- }] });
625
-
626
- /**
627
- * @license
628
- * Copyright (C) Gnucoop soc. coop.
629
- *
630
- * This file is part of the Advanced JSON forms (ajf).
631
- *
632
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
633
- * modify it under the terms of the GNU Affero General Public License as
634
- * published by the Free Software Foundation, either version 3 of the License,
635
- * or (at your option) any later version.
636
- *
637
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
638
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
639
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
640
- * General Public License for more details.
641
- *
642
- * You should have received a copy of the GNU Affero General Public License
643
- * along with Advanced JSON forms (ajf).
644
- * If not, see http://www.gnu.org/licenses/.
645
- *
646
- */
647
- class AjfEthiopianDatePipe {
648
- transform(value) {
649
- try {
650
- const ed = EthiopianDate.gregorianToEthiopian(value);
651
- const date = `0${ed.getDate()}`.slice(-2);
652
- const month = `0${ed.getMonth() + 1}`.slice(-2);
653
- return `${date}/${month}/${ed.getFullYear()}`;
654
- }
655
- catch (e) {
656
- return null;
657
- }
658
- }
659
- }
660
- AjfEthiopianDatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianDatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
661
- AjfEthiopianDatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianDatePipe, name: "ajfEthiopianDate" });
662
- AjfEthiopianDatePipe.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianDatePipe });
663
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianDatePipe, decorators: [{
664
- type: Injectable
665
- }, {
666
- type: Pipe,
667
- args: [{ name: 'ajfEthiopianDate' }]
668
- }] });
669
-
670
- /**
671
- * @license
672
- * Copyright (C) Gnucoop soc. coop.
673
- *
674
- * This file is part of the Advanced JSON forms (ajf).
675
- *
676
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
677
- * modify it under the terms of the GNU Affero General Public License as
678
- * published by the Free Software Foundation, either version 3 of the License,
679
- * or (at your option) any later version.
680
- *
681
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
682
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
683
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
684
- * General Public License for more details.
685
- *
686
- * You should have received a copy of the GNU Affero General Public License
687
- * along with Advanced JSON forms (ajf).
688
- * If not, see http://www.gnu.org/licenses/.
689
- *
690
- */
691
- class AjfEthiopianCalendarModule {
692
- }
693
- AjfEthiopianCalendarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianCalendarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
694
- AjfEthiopianCalendarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianCalendarModule, declarations: [AjfEthiopianDatePipe], exports: [AjfEthiopianDatePipe] });
695
- AjfEthiopianCalendarModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianCalendarModule, providers: [{ provide: AjfCalendarService, useClass: AjfEthiopianCalendarService }] });
696
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: AjfEthiopianCalendarModule, decorators: [{
697
- type: NgModule,
698
- args: [{
699
- declarations: [AjfEthiopianDatePipe],
700
- exports: [AjfEthiopianDatePipe],
701
- providers: [{ provide: AjfCalendarService, useClass: AjfEthiopianCalendarService }],
702
- }]
703
- }] });
704
-
705
- /**
706
- * @license
707
- * Copyright (C) Gnucoop soc. coop.
708
- *
709
- * This file is part of the Advanced JSON forms (ajf).
710
- *
711
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
712
- * modify it under the terms of the GNU Affero General Public License as
713
- * published by the Free Software Foundation, either version 3 of the License,
714
- * or (at your option) any later version.
715
- *
716
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
717
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
718
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
719
- * General Public License for more details.
720
- *
721
- * You should have received a copy of the GNU Affero General Public License
722
- * along with Advanced JSON forms (ajf).
723
- * If not, see http://www.gnu.org/licenses/.
724
- *
725
- */
726
-
727
- /**
728
- * Generated bundle index. Do not edit.
729
- */
730
-
731
- export { AjfEthiopianCalendarModule, AjfEthiopianCalendarService, AjfEthiopianDatePipe, EthiopianDate };
732
- //# sourceMappingURL=ajf-calendars-ethiopian.mjs.map