@ajf/calendars 13.0.0-next.2 → 13.0.0-rc.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 (44) hide show
  1. package/esm2020/ethiopian/calendar-module.mjs +40 -0
  2. package/{esm2015/ethiopian/calendar-service.js → esm2020/ethiopian/calendar-service.mjs} +10 -8
  3. package/esm2020/ethiopian/converter.mjs +154 -0
  4. package/esm2020/ethiopian/ethiopian-date-pipe.mjs +47 -0
  5. package/esm2020/ethiopian/ethiopian-date.mjs +204 -0
  6. package/esm2020/ethiopian/ethiopian_public_index.mjs +5 -0
  7. package/esm2020/ethiopian/index.mjs +23 -0
  8. package/{esm2015/ethiopian/public-api.js → esm2020/ethiopian/public-api.mjs} +0 -0
  9. package/esm2020/ethiopian/utils.mjs +53 -0
  10. package/{esm2015/index.js → esm2020/index.mjs} +0 -0
  11. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  12. package/{esm2015/version.js → esm2020/version.mjs} +1 -1
  13. package/ethiopian/calendar-module.d.ts +5 -21
  14. package/ethiopian/calendar-service.d.ts +3 -0
  15. package/ethiopian/converter.d.ts +1 -5
  16. package/ethiopian/ethiopian-date-pipe.d.ts +4 -0
  17. package/ethiopian/ethiopian-date.d.ts +11 -1
  18. package/ethiopian/ethiopian_public_index.d.ts +4 -0
  19. package/ethiopian/index.d.ts +19 -1
  20. package/ethiopian/package.json +6 -6
  21. package/fesm2015/{calendars.js → calendars.mjs} +2 -2
  22. package/fesm2015/calendars.mjs.map +1 -0
  23. package/fesm2015/{ethiopian.js → ethiopian.mjs} +137 -54
  24. package/fesm2015/ethiopian.mjs.map +1 -0
  25. package/fesm2020/calendars.mjs +72 -0
  26. package/fesm2020/calendars.mjs.map +1 -0
  27. package/fesm2020/ethiopian.mjs +750 -0
  28. package/fesm2020/ethiopian.mjs.map +1 -0
  29. package/package.json +30 -8
  30. package/bundles/calendars-ethiopian.umd.js +0 -984
  31. package/bundles/calendars-ethiopian.umd.js.map +0 -1
  32. package/bundles/calendars.umd.js +0 -80
  33. package/bundles/calendars.umd.js.map +0 -1
  34. package/esm2015/calendars.externs.js +0 -0
  35. package/esm2015/ethiopian/calendar-module.js +0 -41
  36. package/esm2015/ethiopian/converter.js +0 -140
  37. package/esm2015/ethiopian/ethiopian-date-pipe.js +0 -41
  38. package/esm2015/ethiopian/ethiopian-date.js +0 -188
  39. package/esm2015/ethiopian/ethiopian.externs.js +0 -6
  40. package/esm2015/ethiopian/index.js +0 -5
  41. package/esm2015/ethiopian/utils.js +0 -27
  42. package/ethiopian/index.metadata.json +0 -1
  43. package/fesm2015/calendars.js.map +0 -1
  44. package/fesm2015/ethiopian.js.map +0 -1
@@ -1,984 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@ajf/core/calendar'), require('@angular/core'), require('date-fns')) :
3
- typeof define === 'function' && define.amd ? define('@ajf/calendars/ethiopian', ['exports', '@ajf/core/calendar', '@angular/core', 'date-fns'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ajf = global.ajf || {}, global.ajf.calendars = global.ajf.calendars || {}, global.ajf.calendars.ethiopian = {}), global.ajf.core.calendar, global.ng.core, global.dateFns));
5
- }(this, (function (exports, calendar, i0, dateFns) { 'use strict';
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () {
17
- return e[k];
18
- }
19
- });
20
- }
21
- });
22
- }
23
- n['default'] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
-
29
- /*! *****************************************************************************
30
- Copyright (c) Microsoft Corporation.
31
-
32
- Permission to use, copy, modify, and/or distribute this software for any
33
- purpose with or without fee is hereby granted.
34
-
35
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
37
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41
- PERFORMANCE OF THIS SOFTWARE.
42
- ***************************************************************************** */
43
- /* global Reflect, Promise */
44
- var extendStatics = function (d, b) {
45
- extendStatics = Object.setPrototypeOf ||
46
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
47
- function (d, b) { for (var p in b)
48
- if (Object.prototype.hasOwnProperty.call(b, p))
49
- d[p] = b[p]; };
50
- return extendStatics(d, b);
51
- };
52
- function __extends(d, b) {
53
- if (typeof b !== "function" && b !== null)
54
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
55
- extendStatics(d, b);
56
- function __() { this.constructor = d; }
57
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
58
- }
59
- var __assign = function () {
60
- __assign = Object.assign || function __assign(t) {
61
- for (var s, i = 1, n = arguments.length; i < n; i++) {
62
- s = arguments[i];
63
- for (var p in s)
64
- if (Object.prototype.hasOwnProperty.call(s, p))
65
- t[p] = s[p];
66
- }
67
- return t;
68
- };
69
- return __assign.apply(this, arguments);
70
- };
71
- function __rest(s, e) {
72
- var t = {};
73
- for (var p in s)
74
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
- t[p] = s[p];
76
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
- t[p[i]] = s[p[i]];
80
- }
81
- return t;
82
- }
83
- function __decorate(decorators, target, key, desc) {
84
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
85
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
86
- r = Reflect.decorate(decorators, target, key, desc);
87
- else
88
- for (var i = decorators.length - 1; i >= 0; i--)
89
- if (d = decorators[i])
90
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
91
- return c > 3 && r && Object.defineProperty(target, key, r), r;
92
- }
93
- function __param(paramIndex, decorator) {
94
- return function (target, key) { decorator(target, key, paramIndex); };
95
- }
96
- function __metadata(metadataKey, metadataValue) {
97
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
98
- return Reflect.metadata(metadataKey, metadataValue);
99
- }
100
- function __awaiter(thisArg, _arguments, P, generator) {
101
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
102
- return new (P || (P = Promise))(function (resolve, reject) {
103
- function fulfilled(value) { try {
104
- step(generator.next(value));
105
- }
106
- catch (e) {
107
- reject(e);
108
- } }
109
- function rejected(value) { try {
110
- step(generator["throw"](value));
111
- }
112
- catch (e) {
113
- reject(e);
114
- } }
115
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
116
- step((generator = generator.apply(thisArg, _arguments || [])).next());
117
- });
118
- }
119
- function __generator(thisArg, body) {
120
- var _ = { label: 0, sent: function () { if (t[0] & 1)
121
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
122
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
123
- function verb(n) { return function (v) { return step([n, v]); }; }
124
- function step(op) {
125
- if (f)
126
- throw new TypeError("Generator is already executing.");
127
- while (_)
128
- try {
129
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
130
- return t;
131
- if (y = 0, t)
132
- op = [op[0] & 2, t.value];
133
- switch (op[0]) {
134
- case 0:
135
- case 1:
136
- t = op;
137
- break;
138
- case 4:
139
- _.label++;
140
- return { value: op[1], done: false };
141
- case 5:
142
- _.label++;
143
- y = op[1];
144
- op = [0];
145
- continue;
146
- case 7:
147
- op = _.ops.pop();
148
- _.trys.pop();
149
- continue;
150
- default:
151
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
152
- _ = 0;
153
- continue;
154
- }
155
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
156
- _.label = op[1];
157
- break;
158
- }
159
- if (op[0] === 6 && _.label < t[1]) {
160
- _.label = t[1];
161
- t = op;
162
- break;
163
- }
164
- if (t && _.label < t[2]) {
165
- _.label = t[2];
166
- _.ops.push(op);
167
- break;
168
- }
169
- if (t[2])
170
- _.ops.pop();
171
- _.trys.pop();
172
- continue;
173
- }
174
- op = body.call(thisArg, _);
175
- }
176
- catch (e) {
177
- op = [6, e];
178
- y = 0;
179
- }
180
- finally {
181
- f = t = 0;
182
- }
183
- if (op[0] & 5)
184
- throw op[1];
185
- return { value: op[0] ? op[1] : void 0, done: true };
186
- }
187
- }
188
- var __createBinding = Object.create ? (function (o, m, k, k2) {
189
- if (k2 === undefined)
190
- k2 = k;
191
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
192
- }) : (function (o, m, k, k2) {
193
- if (k2 === undefined)
194
- k2 = k;
195
- o[k2] = m[k];
196
- });
197
- function __exportStar(m, o) {
198
- for (var p in m)
199
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
200
- __createBinding(o, m, p);
201
- }
202
- function __values(o) {
203
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
204
- if (m)
205
- return m.call(o);
206
- if (o && typeof o.length === "number")
207
- return {
208
- next: function () {
209
- if (o && i >= o.length)
210
- o = void 0;
211
- return { value: o && o[i++], done: !o };
212
- }
213
- };
214
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
215
- }
216
- function __read(o, n) {
217
- var m = typeof Symbol === "function" && o[Symbol.iterator];
218
- if (!m)
219
- return o;
220
- var i = m.call(o), r, ar = [], e;
221
- try {
222
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
223
- ar.push(r.value);
224
- }
225
- catch (error) {
226
- e = { error: error };
227
- }
228
- finally {
229
- try {
230
- if (r && !r.done && (m = i["return"]))
231
- m.call(i);
232
- }
233
- finally {
234
- if (e)
235
- throw e.error;
236
- }
237
- }
238
- return ar;
239
- }
240
- /** @deprecated */
241
- function __spread() {
242
- for (var ar = [], i = 0; i < arguments.length; i++)
243
- ar = ar.concat(__read(arguments[i]));
244
- return ar;
245
- }
246
- /** @deprecated */
247
- function __spreadArrays() {
248
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
249
- s += arguments[i].length;
250
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
251
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
252
- r[k] = a[j];
253
- return r;
254
- }
255
- function __spreadArray(to, from, pack) {
256
- if (pack || arguments.length === 2)
257
- for (var i = 0, l = from.length, ar; i < l; i++) {
258
- if (ar || !(i in from)) {
259
- if (!ar)
260
- ar = Array.prototype.slice.call(from, 0, i);
261
- ar[i] = from[i];
262
- }
263
- }
264
- return to.concat(ar || Array.prototype.slice.call(from));
265
- }
266
- function __await(v) {
267
- return this instanceof __await ? (this.v = v, this) : new __await(v);
268
- }
269
- function __asyncGenerator(thisArg, _arguments, generator) {
270
- if (!Symbol.asyncIterator)
271
- throw new TypeError("Symbol.asyncIterator is not defined.");
272
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
273
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
274
- function verb(n) { if (g[n])
275
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
276
- function resume(n, v) { try {
277
- step(g[n](v));
278
- }
279
- catch (e) {
280
- settle(q[0][3], e);
281
- } }
282
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
283
- function fulfill(value) { resume("next", value); }
284
- function reject(value) { resume("throw", value); }
285
- function settle(f, v) { if (f(v), q.shift(), q.length)
286
- resume(q[0][0], q[0][1]); }
287
- }
288
- function __asyncDelegator(o) {
289
- var i, p;
290
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
291
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
292
- }
293
- function __asyncValues(o) {
294
- if (!Symbol.asyncIterator)
295
- throw new TypeError("Symbol.asyncIterator is not defined.");
296
- var m = o[Symbol.asyncIterator], i;
297
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
298
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
299
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
300
- }
301
- function __makeTemplateObject(cooked, raw) {
302
- if (Object.defineProperty) {
303
- Object.defineProperty(cooked, "raw", { value: raw });
304
- }
305
- else {
306
- cooked.raw = raw;
307
- }
308
- return cooked;
309
- }
310
- ;
311
- var __setModuleDefault = Object.create ? (function (o, v) {
312
- Object.defineProperty(o, "default", { enumerable: true, value: v });
313
- }) : function (o, v) {
314
- o["default"] = v;
315
- };
316
- function __importStar(mod) {
317
- if (mod && mod.__esModule)
318
- return mod;
319
- var result = {};
320
- if (mod != null)
321
- for (var k in mod)
322
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
323
- __createBinding(result, mod, k);
324
- __setModuleDefault(result, mod);
325
- return result;
326
- }
327
- function __importDefault(mod) {
328
- return (mod && mod.__esModule) ? mod : { default: mod };
329
- }
330
- function __classPrivateFieldGet(receiver, state, kind, f) {
331
- if (kind === "a" && !f)
332
- throw new TypeError("Private accessor was defined without a getter");
333
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
334
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
335
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
336
- }
337
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
338
- if (kind === "m")
339
- throw new TypeError("Private method is not writable");
340
- if (kind === "a" && !f)
341
- throw new TypeError("Private accessor was defined without a setter");
342
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
343
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
344
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
345
- }
346
-
347
- /**
348
- * @license
349
- * Copyright (C) Gnucoop soc. coop.
350
- *
351
- * This file is part of the Advanced JSON forms (ajf).
352
- *
353
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
354
- * modify it under the terms of the GNU Affero General Public License as
355
- * published by the Free Software Foundation, either version 3 of the License,
356
- * or (at your option) any later version.
357
- *
358
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
359
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
360
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
361
- * General Public License for more details.
362
- *
363
- * You should have received a copy of the GNU Affero General Public License
364
- * along with Advanced JSON forms (ajf).
365
- * If not, see http://www.gnu.org/licenses/.
366
- *
367
- */
368
- var JD_EPOCH_OFFSET_AMETE_ALEM = -285019; // ዓ/ዓ
369
- var JD_EPOCH_OFFSET_AMETE_MIHRET = 1723856; // ዓ/ም
370
- var JD_EPOCH_OFFSET_GREGORIAN = 1721426;
371
- var JD_EPOCH_OFFSET_UNSET = -1;
372
- var JDN_OFFSET = JD_EPOCH_OFFSET_UNSET;
373
- var GREGORIAN_NUMBER_OF_MONTHS = 12;
374
- var monthDays = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
375
- function quotient(i, j) {
376
- return Math.floor(i / j);
377
- }
378
- function isGregorianLeap(year) {
379
- return (year % 4 === 0) && ((year % 100 !== 0) || (year % 400 === 0));
380
- }
381
- function setEra(era) {
382
- if ((era === JD_EPOCH_OFFSET_AMETE_ALEM) || (era === JD_EPOCH_OFFSET_AMETE_MIHRET)) {
383
- JDN_OFFSET = era;
384
- }
385
- else {
386
- throw (new Error("Unknown Era: " + era));
387
- }
388
- }
389
- function isEraSet() {
390
- return JD_EPOCH_OFFSET_UNSET !== JDN_OFFSET;
391
- }
392
- function unsetEra() {
393
- JDN_OFFSET = JD_EPOCH_OFFSET_UNSET;
394
- }
395
- function guessEraFromJDN(jdn) {
396
- return (jdn >= (JD_EPOCH_OFFSET_AMETE_MIHRET + 365)) ? JD_EPOCH_OFFSET_AMETE_MIHRET :
397
- JD_EPOCH_OFFSET_AMETE_ALEM;
398
- }
399
- function ethiopicToJDN(day, month, year) {
400
- var ERA = isEraSet() ? JDN_OFFSET : JD_EPOCH_OFFSET_AMETE_MIHRET;
401
- var jdn = (ERA + 365) + 365 * (year - 1) + quotient(year, 4) + 30 * month + day - 31;
402
- return jdn;
403
- }
404
- function jdnToEthiopic(jdn) {
405
- var ERA = isEraSet() ? JDN_OFFSET : guessEraFromJDN(jdn);
406
- var r = (jdn - ERA) % 1461;
407
- var n = (r % 365) + 365 * quotient(r, 1460);
408
- var year = 4 * quotient((jdn - ERA), 1461) + quotient(r, 365) - quotient(r, 1460);
409
- var month = quotient(n, 30) + 1;
410
- var day = (n % 30) + 1;
411
- return [year, month, day];
412
- }
413
- function gregorianToJDN(day, month, year) {
414
- var s = quotient(year, 4) - quotient(year - 1, 4) - quotient(year, 100) +
415
- quotient(year - 1, 100) + quotient(year, 400) - quotient(year - 1, 400);
416
- var t = quotient(14 - month, 12);
417
- var n = 31 * t * (month - 1) +
418
- (1 - t) * (59 + s + 30 * (month - 3) + quotient((3 * month - 7), 5)) + day - 1;
419
- var j = JD_EPOCH_OFFSET_GREGORIAN + 365 * (year - 1) + quotient(year - 1, 4) -
420
- quotient(year - 1, 100) + quotient(year - 1, 400) + n;
421
- return j;
422
- }
423
- function jdnToGregorian(jdn) {
424
- var r2000 = (jdn - JD_EPOCH_OFFSET_GREGORIAN) % 730485;
425
- var r400 = (jdn - JD_EPOCH_OFFSET_GREGORIAN) % 146097;
426
- var r100 = r400 % 36524;
427
- var r4 = r100 % 1461;
428
- var n = (r4 % 365) + 365 * quotient(r4, 1460);
429
- var s = quotient(r4, 1095);
430
- var aprime = 400 * quotient((jdn - JD_EPOCH_OFFSET_GREGORIAN), 146097) +
431
- 100 * quotient(r400, 36524) + 4 * quotient(r100, 1461) + quotient(r4, 365) -
432
- quotient(r4, 1460) - quotient(r2000, 730484);
433
- var year = aprime + 1;
434
- var t = quotient((364 + s - n), 306);
435
- var month = t * (quotient(n, 31) + 1) + (1 - t) * (quotient((5 * (n - s) + 13), 153) + 1);
436
- n += 1 - quotient(r2000, 730484);
437
- var day = n;
438
- if ((r100 === 0) && (n === 0) && (r400 !== 0)) {
439
- month = 12;
440
- day = 31;
441
- }
442
- else {
443
- monthDays[2] = (isGregorianLeap(year)) ? 29 : 28;
444
- for (var i = 1; i <= GREGORIAN_NUMBER_OF_MONTHS; i += 1) {
445
- if (n <= monthDays[i]) {
446
- day = n;
447
- break;
448
- }
449
- n -= monthDays[i];
450
- }
451
- }
452
- return [year, month, day];
453
- }
454
- function gregorianToEthiopic(day, month, year) {
455
- var jdn = gregorianToJDN(day, month, year);
456
- return jdnToEthiopic(jdn);
457
- }
458
- function ethioipicToGreg(day, month, year) {
459
- var jdn = ethiopicToJDN(day, month, year);
460
- return jdnToGregorian(jdn);
461
- }
462
- function ethioipicToGregorian(day, month, year, era) {
463
- setEra(era);
464
- var result = ethioipicToGreg(day, month, year);
465
- unsetEra();
466
- return result;
467
- }
468
- /** API * */
469
- /** ethiopian to gregorian */
470
- function toGC(dateArray) {
471
- var _a = __read(dateArray, 3), y = _a[0], m = _a[1], d = _a[2];
472
- var era = dateArray.length === 4 ? dateArray[3] : JD_EPOCH_OFFSET_AMETE_MIHRET;
473
- if (d < 0 || d > 30 || m < 0 || m > 13) {
474
- throw new Error('Invalid Ethiopian Date');
475
- }
476
- return ethioipicToGregorian(d, m, y, era);
477
- }
478
- /** gregorian to ethiopian */
479
- function toEC(dateArray) {
480
- var _a = __read(dateArray, 3), y = _a[0], m = _a[1], d = _a[2];
481
- if (d < 0 || d > 31 || m < 0 || m > 12) {
482
- throw new Error('Invalid Gregorian Date');
483
- }
484
- return gregorianToEthiopic(d, m, y);
485
- }
486
-
487
- /**
488
- * @license
489
- * Copyright (C) Gnucoop soc. coop.
490
- *
491
- * This file is part of the Advanced JSON forms (ajf).
492
- *
493
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
494
- * modify it under the terms of the GNU Affero General Public License as
495
- * published by the Free Software Foundation, either version 3 of the License,
496
- * or (at your option) any later version.
497
- *
498
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
499
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
500
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
501
- * General Public License for more details.
502
- *
503
- * You should have received a copy of the GNU Affero General Public License
504
- * along with Advanced JSON forms (ajf).
505
- * If not, see http://www.gnu.org/licenses/.
506
- *
507
- */
508
- var WEEK_NAMES = ['እሑድ', 'ሰኞ', 'ማክሰኞ', 'ረቡዕ', 'ሓሙስ', 'ዓርብ', 'ቅዳሜ'];
509
- var MONTHS_NAMES = [
510
- 'መስከረም', 'ጥቅምት', 'ኅዳር', 'ታኅሣሥ', 'ጥር', 'የካቲት', 'መጋቢት', 'ሚያዝያ', 'ግንቦት', 'ሰኔ', 'ሐምሌ', 'ነሐሴ', 'ጳጉሜን'
511
- ];
512
- var SHORT_MONTHS_NAMES = ['መስከ', 'ጥቅም', 'ኅዳር', 'ታኅሣ', 'ጥር', 'የካቲ', 'መጋቢ', 'ሚያዝ', 'ግንቦ', 'ሰኔ', 'ሐምሌ', 'ነሐሴ', 'ጳጉሜ'];
513
-
514
- var EthiopianDate = /** @class */ (function () {
515
- /**
516
- * @param val - A numeric year value if the second and third parameters ar provided,
517
- * It should be a date string if not
518
- * @param month A zero-based numeric value for the month (0 for መስከረም, 12 for ጳጉሜን)
519
- * @param day A numeric value equal for the day of the month.
520
- */
521
- function EthiopianDate(val, month, day) {
522
- var _a, _b, _c;
523
- if (val == null && month == null && day == null) {
524
- var ahun = EthiopianDate.gregorianToEthiopian(new Date());
525
- _a = __read([ahun.getFullYear(), ahun.getMonth(), ahun.getDate()], 3), this._year = _a[0], this._month = _a[1], this._date = _a[2];
526
- this._gc = EthiopianDate.ethiopianToGregorian(this._year, this._month, this._date);
527
- }
528
- else if (val != null && month == null && day == null && typeof val !== 'number') {
529
- if (typeof val === 'string') {
530
- var result = EthiopianDate.parse(val);
531
- if (result == null) {
532
- throw new Error('Invalid Argument Exception');
533
- }
534
- _b = __read([result.getFullYear(), result.getMonth(), result.getDate()], 3), this._year = _b[0], this._month = _b[1], this._date = _b[2];
535
- this._gc = EthiopianDate.ethiopianToGregorian(this._year, this._month, this._date);
536
- }
537
- else if (typeof val === 'object' && val instanceof Date) {
538
- var result = EthiopianDate.gregorianToEthiopian(val.getFullYear(), val.getMonth() + 1, val.getDate());
539
- _c = __read([result.getFullYear(), result.getMonth(), result.getDate()], 3), this._year = _c[0], this._month = _c[1], this._date = _c[2];
540
- this._gc = EthiopianDate.ethiopianToGregorian(this._year, this._month, this._date);
541
- }
542
- else {
543
- throw new Error('Invalid Argument Exception');
544
- }
545
- }
546
- else if (val != null && month != null && day != null && typeof val === 'number') {
547
- this._year = val;
548
- this._month = month;
549
- this._date = day;
550
- this._gc = EthiopianDate.ethiopianToGregorian(this._year, this._month, this._date);
551
- }
552
- }
553
- EthiopianDate.prototype.getDate = function () {
554
- return this._date;
555
- };
556
- EthiopianDate.prototype.getDay = function () {
557
- return this._gc.getDay();
558
- };
559
- EthiopianDate.prototype.getDayOfWeek = function () {
560
- var weekDay = this.getGCWeekDay();
561
- return WEEK_NAMES[weekDay];
562
- };
563
- EthiopianDate.prototype.getFullYear = function () {
564
- return this._year;
565
- };
566
- EthiopianDate.prototype.getGregorianDate = function () {
567
- return this._gc;
568
- };
569
- EthiopianDate.prototype.getGCWeekDay = function () {
570
- return this._gc.getDay();
571
- };
572
- EthiopianDate.prototype.getMonth = function () {
573
- return this._month;
574
- };
575
- EthiopianDate.prototype.getMonthName = function () {
576
- return this._month >= 0 && this._month < MONTHS_NAMES.length ? MONTHS_NAMES[this._month] : null;
577
- };
578
- EthiopianDate.prototype.getShortMonthName = function () {
579
- return this._month >= 0 && this._month < SHORT_MONTHS_NAMES.length ?
580
- SHORT_MONTHS_NAMES[this._month] :
581
- null;
582
- };
583
- EthiopianDate.prototype.getHours = function () {
584
- return 0;
585
- };
586
- EthiopianDate.prototype.getMinutes = function () {
587
- return 0;
588
- };
589
- EthiopianDate.prototype.getSeconds = function () {
590
- return 0;
591
- };
592
- EthiopianDate.prototype.getMilliseconds = function () {
593
- return 0;
594
- };
595
- EthiopianDate.prototype.toString = function () {
596
- return this._year + "-" + (this._month + 1) + "-" + this._date;
597
- };
598
- /**
599
- * Converts a Ethiopian date to Gregorian and returns Date instance representing Gregorian Date.
600
- *
601
- * @param val - A numeric year value if the second and third parameters are
602
- * provided, it should be a date string if not
603
- * @param month A zero-based numeric value for the month
604
- * (0 for January, 11 for December)
605
- * @param day A numeric value equal for the day of the month.
606
- *
607
- * @api public
608
- */
609
- EthiopianDate.ethiopianToGregorian = function (val, month, day) {
610
- var ec;
611
- if (val != null && month == null && day == null && typeof val !== 'number') {
612
- if (typeof val === 'string') {
613
- var etDate = new EthiopianDate(val);
614
- ec = [etDate.getFullYear(), etDate.getMonth() + 1, etDate.getDate()];
615
- }
616
- else if (typeof val === 'object' && val instanceof EthiopianDate) {
617
- var _a = __read([val.getFullYear(), val.getMonth() + 1, val.getDate()], 3), y = _a[0], m = _a[1], d = _a[2];
618
- ec = [y, m, d];
619
- }
620
- else {
621
- throw new Error('Invalid Argument Exception');
622
- }
623
- }
624
- else if (val != null && month != null && day != null && typeof val === 'number') {
625
- ec = [val, month + 1, day];
626
- }
627
- else {
628
- throw new Error('Invalid Argument Exception');
629
- }
630
- var gc = toGC(ec);
631
- return new Date(gc[0], gc[1] - 1, gc[2]);
632
- };
633
- EthiopianDate.gregorianToEthiopian = function (val, month, day) {
634
- var gc;
635
- if (val != null && month == null && day == null && typeof val !== 'number') {
636
- if (typeof val === 'string') {
637
- var gcDate = new Date(val);
638
- gc = [gcDate.getFullYear(), gcDate.getMonth() + 1, gcDate.getDate()];
639
- }
640
- else if (typeof val === 'object' && val instanceof Date) {
641
- var _a = __read([val.getFullYear(), val.getMonth() + 1, val.getDate()], 3), y = _a[0], m = _a[1], d = _a[2];
642
- gc = [y, m, d];
643
- }
644
- else {
645
- throw new Error('Invalid Argument Exception');
646
- }
647
- }
648
- else if (val != null && month != null && day != null && typeof val === 'number') {
649
- gc = [val, month + 1, day];
650
- }
651
- else {
652
- throw new Error('Invalid Argument Exception');
653
- }
654
- var ec = toEC(gc);
655
- return new EthiopianDate(ec[0], ec[1] - 1, ec[2]);
656
- };
657
- /**
658
- * Parse Ethiopian date from string
659
- *
660
- * @param dateString a date string to parse
661
- * @param pattern a parsing pattern
662
- *
663
- * @returns EthiopianDate
664
- */
665
- EthiopianDate.parse = function (dateString) {
666
- if (!dateString) {
667
- return null;
668
- }
669
- var result = dateString.split('-');
670
- if (result.length === 3) {
671
- var _a = __read(result, 3), y = _a[0], m = _a[1], d = _a[2];
672
- return new EthiopianDate(parseInt(y, 10), parseInt(m, 10) - 1, parseInt(d, 10));
673
- }
674
- throw new Error("ParsingError: Can't parse " + dateString);
675
- };
676
- return EthiopianDate;
677
- }());
678
-
679
- function getMonthDays(month, year) {
680
- if (month < 12) {
681
- return 30;
682
- }
683
- return year % 4 === 3 ? 6 : 5;
684
- }
685
- function getMonthBounds(date) {
686
- var year = date.getFullYear();
687
- var month = date.getMonth();
688
- var start = new EthiopianDate(year, month, 1);
689
- var endDay = getMonthDays(month, year);
690
- var end = new EthiopianDate(year, month, endDay);
691
- return { start: start, end: end };
692
- }
693
- var AjfEthiopianCalendarService = /** @class */ (function (_super) {
694
- __extends(AjfEthiopianCalendarService, _super);
695
- function AjfEthiopianCalendarService() {
696
- return _super !== null && _super.apply(this, arguments) || this;
697
- }
698
- AjfEthiopianCalendarService.prototype.buildView = function (params) {
699
- var viewMode = params.viewMode;
700
- var viewDate = EthiopianDate.gregorianToEthiopian(params.viewDate);
701
- switch (viewMode) {
702
- case 'decade':
703
- var curYear = viewDate.getFullYear();
704
- var firstYear = curYear - (curYear % 10) + 1;
705
- var lastYear = firstYear + 11;
706
- return {
707
- header: firstYear + " - " + lastYear,
708
- headerRow: [],
709
- rows: this._ecDecadeCalendarRows(params),
710
- };
711
- case 'year':
712
- return {
713
- header: "" + viewDate.getFullYear(),
714
- headerRow: [],
715
- rows: this._ecYearCalendarRows(params),
716
- };
717
- case 'month':
718
- var view = _super.prototype.buildView.call(this, params);
719
- return {
720
- header: viewDate.getShortMonthName() + " " + viewDate.getFullYear(),
721
- headerRow: this._ecMonthHeaderRow(params),
722
- rows: view.rows,
723
- };
724
- }
725
- return _super.prototype.buildView.call(this, params);
726
- };
727
- AjfEthiopianCalendarService.prototype.entryLabel = function (entry) {
728
- var ecDate = EthiopianDate.gregorianToEthiopian(entry.date);
729
- if (entry.type === 'day') {
730
- return "" + ecDate.getDate();
731
- }
732
- if (entry.type === 'month') {
733
- return "" + ecDate.getMonthName();
734
- }
735
- return "" + ecDate.getFullYear();
736
- };
737
- AjfEthiopianCalendarService.prototype.monthBounds = function (date, isoMode) {
738
- if (!isoMode) {
739
- var ecDate = EthiopianDate.gregorianToEthiopian(date);
740
- var _a = getMonthBounds(ecDate), start = _a.start, end = _a.end;
741
- return {
742
- start: EthiopianDate.ethiopianToGregorian(start),
743
- end: EthiopianDate.ethiopianToGregorian(end),
744
- };
745
- }
746
- else {
747
- var isoDay = dateFns.getISODay(date);
748
- var ecDate = EthiopianDate.gregorianToEthiopian(date);
749
- var _b = getMonthBounds(ecDate), start = _b.start, end = _b.end;
750
- if (ecDate.getMonth() === 12) {
751
- start = EthiopianDate.gregorianToEthiopian(dateFns.startOfISOWeek(start.getGregorianDate()));
752
- end = EthiopianDate.gregorianToEthiopian(dateFns.endOfISOWeek(end.getGregorianDate()));
753
- }
754
- else {
755
- date = isoDay < 4 ? dateFns.endOfISOWeek(date) : dateFns.startOfISOWeek(date);
756
- var startWeekDay = start.getDay();
757
- var endWeekDay = end.getDay();
758
- if (startWeekDay == 0 || startWeekDay > 4) {
759
- start = EthiopianDate.gregorianToEthiopian(dateFns.addWeeks(start.getGregorianDate(), 1));
760
- }
761
- if (endWeekDay > 0 && endWeekDay < 4) {
762
- end = EthiopianDate.gregorianToEthiopian(dateFns.subWeeks(end.getGregorianDate(), 1));
763
- }
764
- }
765
- return {
766
- start: dateFns.startOfISOWeek(start.getGregorianDate()),
767
- end: dateFns.endOfISOWeek(end.getGregorianDate()),
768
- };
769
- }
770
- };
771
- AjfEthiopianCalendarService.prototype.nextView = function (viewDate, viewMode) {
772
- if (viewMode === 'month') {
773
- var ecDate = EthiopianDate.gregorianToEthiopian(viewDate);
774
- var year = ecDate.getFullYear();
775
- var month = ecDate.getMonth();
776
- if (month === 12) {
777
- month = 0;
778
- year += 1;
779
- }
780
- else {
781
- month += 1;
782
- }
783
- return EthiopianDate.ethiopianToGregorian(new EthiopianDate(year, month, 1));
784
- }
785
- return _super.prototype.nextView.call(this, viewDate, viewMode);
786
- };
787
- AjfEthiopianCalendarService.prototype.previousView = function (viewDate, viewMode) {
788
- if (viewMode === 'month') {
789
- var ecDate = EthiopianDate.gregorianToEthiopian(viewDate);
790
- var year = ecDate.getFullYear();
791
- var month = ecDate.getMonth();
792
- if (month === 0) {
793
- month = 12;
794
- year -= 1;
795
- }
796
- else {
797
- month -= 1;
798
- }
799
- return EthiopianDate.ethiopianToGregorian(new EthiopianDate(year, month, 1));
800
- }
801
- return _super.prototype.previousView.call(this, viewDate, viewMode);
802
- };
803
- AjfEthiopianCalendarService.prototype._ecMonthHeaderRow = function (params) {
804
- var isoMode = params.isoMode, viewDate = params.viewDate;
805
- var curDate;
806
- if (isoMode) {
807
- curDate = dateFns.setISODay(dateFns.startOfWeek(viewDate), 1);
808
- }
809
- else {
810
- curDate = dateFns.startOfWeek(viewDate);
811
- }
812
- var weekDayNames = [];
813
- for (var i = 0; i < 7; i++) {
814
- var ecDate = EthiopianDate.gregorianToEthiopian(curDate);
815
- weekDayNames.push(ecDate.getDayOfWeek());
816
- curDate = dateFns.addDays(curDate, 1);
817
- }
818
- return weekDayNames;
819
- };
820
- AjfEthiopianCalendarService.prototype._ecYearCalendarRows = function (params) {
821
- var viewDate = params.viewDate, selection = params.selection;
822
- var year = EthiopianDate.gregorianToEthiopian(viewDate).getFullYear();
823
- var curDate;
824
- var rows = [];
825
- for (var i = 0; i <= 4; i++) {
826
- var row = [];
827
- for (var j = 0; j < 3; j++) {
828
- var curMonth = i * 3 + j;
829
- if (curMonth < 13) {
830
- curDate = new EthiopianDate(year, curMonth, 1);
831
- var date = EthiopianDate.ethiopianToGregorian(curDate);
832
- var newEntry = { type: 'month', date: date, selected: 'none' };
833
- newEntry.selected = this.isEntrySelected(newEntry, selection);
834
- row.push(newEntry);
835
- }
836
- }
837
- rows.push(row);
838
- }
839
- return rows;
840
- };
841
- AjfEthiopianCalendarService.prototype._ecDecadeCalendarRows = function (params) {
842
- var viewDate = params.viewDate, selection = params.selection;
843
- var ecDate = EthiopianDate.gregorianToEthiopian(viewDate);
844
- var curYear = ecDate.getFullYear();
845
- var firstYear = curYear - (curYear % 10) + 1;
846
- var curDate = EthiopianDate.ethiopianToGregorian(firstYear, 1, 1);
847
- var rows = [];
848
- for (var i = 0; i < 4; i++) {
849
- var row = [];
850
- for (var j = 0; j < 3; j++) {
851
- var date = new Date(curDate);
852
- var newEntry = { type: 'year', date: date, selected: 'none' };
853
- newEntry.selected = this.isEntrySelected(newEntry, selection);
854
- row.push(newEntry);
855
- curDate = dateFns.addYears(curDate, 1);
856
- }
857
- rows.push(row);
858
- }
859
- return rows;
860
- };
861
- return AjfEthiopianCalendarService;
862
- }(calendar.AjfCalendarService));
863
- AjfEthiopianCalendarService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function AjfEthiopianCalendarService_Factory() { return new AjfEthiopianCalendarService(); }, token: AjfEthiopianCalendarService, providedIn: "root" });
864
- AjfEthiopianCalendarService.decorators = [
865
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
866
- ];
867
-
868
- /**
869
- * @license
870
- * Copyright (C) Gnucoop soc. coop.
871
- *
872
- * This file is part of the Advanced JSON forms (ajf).
873
- *
874
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
875
- * modify it under the terms of the GNU Affero General Public License as
876
- * published by the Free Software Foundation, either version 3 of the License,
877
- * or (at your option) any later version.
878
- *
879
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
880
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
881
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
882
- * General Public License for more details.
883
- *
884
- * You should have received a copy of the GNU Affero General Public License
885
- * along with Advanced JSON forms (ajf).
886
- * If not, see http://www.gnu.org/licenses/.
887
- *
888
- */
889
- var AjfEthiopianDatePipe = /** @class */ (function () {
890
- function AjfEthiopianDatePipe() {
891
- }
892
- AjfEthiopianDatePipe.prototype.transform = function (value) {
893
- try {
894
- var ed = EthiopianDate.gregorianToEthiopian(value);
895
- var date = ("0" + ed.getDate()).slice(-2);
896
- var month = ("0" + ed.getMonth()).slice(-2);
897
- return date + "/" + month + "/" + ed.getFullYear();
898
- }
899
- catch (e) {
900
- return null;
901
- }
902
- };
903
- return AjfEthiopianDatePipe;
904
- }());
905
- AjfEthiopianDatePipe.decorators = [
906
- { type: i0.Injectable },
907
- { type: i0.Pipe, args: [{ name: 'ajfEthiopianDate' },] }
908
- ];
909
-
910
- /**
911
- * @license
912
- * Copyright (C) Gnucoop soc. coop.
913
- *
914
- * This file is part of the Advanced JSON forms (ajf).
915
- *
916
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
917
- * modify it under the terms of the GNU Affero General Public License as
918
- * published by the Free Software Foundation, either version 3 of the License,
919
- * or (at your option) any later version.
920
- *
921
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
922
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
923
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
924
- * General Public License for more details.
925
- *
926
- * You should have received a copy of the GNU Affero General Public License
927
- * along with Advanced JSON forms (ajf).
928
- * If not, see http://www.gnu.org/licenses/.
929
- *
930
- */
931
- var AjfEthiopianCalendarModule = /** @class */ (function () {
932
- function AjfEthiopianCalendarModule() {
933
- }
934
- return AjfEthiopianCalendarModule;
935
- }());
936
- AjfEthiopianCalendarModule.decorators = [
937
- { type: i0.NgModule, args: [{
938
- declarations: [
939
- AjfEthiopianDatePipe,
940
- ],
941
- exports: [
942
- AjfEthiopianDatePipe,
943
- ],
944
- providers: [
945
- { provide: calendar.AjfCalendarService, useClass: AjfEthiopianCalendarService },
946
- ],
947
- },] }
948
- ];
949
-
950
- /**
951
- * @license
952
- * Copyright (C) Gnucoop soc. coop.
953
- *
954
- * This file is part of the Advanced JSON forms (ajf).
955
- *
956
- * Advanced JSON forms (ajf) is free software: you can redistribute it and/or
957
- * modify it under the terms of the GNU Affero General Public License as
958
- * published by the Free Software Foundation, either version 3 of the License,
959
- * or (at your option) any later version.
960
- *
961
- * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,
962
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
963
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
964
- * General Public License for more details.
965
- *
966
- * You should have received a copy of the GNU Affero General Public License
967
- * along with Advanced JSON forms (ajf).
968
- * If not, see http://www.gnu.org/licenses/.
969
- *
970
- */
971
-
972
- /**
973
- * Generated bundle index. Do not edit.
974
- */
975
-
976
- exports.AjfEthiopianCalendarModule = AjfEthiopianCalendarModule;
977
- exports.AjfEthiopianCalendarService = AjfEthiopianCalendarService;
978
- exports.AjfEthiopianDatePipe = AjfEthiopianDatePipe;
979
- exports.EthiopianDate = EthiopianDate;
980
-
981
- Object.defineProperty(exports, '__esModule', { value: true });
982
-
983
- })));
984
- //# sourceMappingURL=calendars-ethiopian.umd.js.map