@internationalized/date 3.5.3-nightly.4555 → 3.5.3-nightly.4560
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BuddhistCalendar.main.js +54 -0
- package/dist/BuddhistCalendar.main.js.map +1 -0
- package/dist/BuddhistCalendar.mjs +49 -0
- package/dist/BuddhistCalendar.module.js +49 -0
- package/dist/BuddhistCalendar.module.js.map +1 -0
- package/dist/CalendarDate.main.js +260 -0
- package/dist/CalendarDate.main.js.map +1 -0
- package/dist/CalendarDate.mjs +252 -0
- package/dist/CalendarDate.module.js +252 -0
- package/dist/CalendarDate.module.js.map +1 -0
- package/dist/DateFormatter.main.js +145 -0
- package/dist/DateFormatter.main.js.map +1 -0
- package/dist/DateFormatter.mjs +140 -0
- package/dist/DateFormatter.module.js +140 -0
- package/dist/DateFormatter.module.js.map +1 -0
- package/dist/EthiopicCalendar.main.js +170 -0
- package/dist/EthiopicCalendar.main.js.map +1 -0
- package/dist/EthiopicCalendar.mjs +163 -0
- package/dist/EthiopicCalendar.module.js +163 -0
- package/dist/EthiopicCalendar.module.js.map +1 -0
- package/dist/GregorianCalendar.main.js +143 -0
- package/dist/GregorianCalendar.main.js.map +1 -0
- package/dist/GregorianCalendar.mjs +134 -0
- package/dist/GregorianCalendar.module.js +134 -0
- package/dist/GregorianCalendar.module.js.map +1 -0
- package/dist/HebrewCalendar.main.js +149 -0
- package/dist/HebrewCalendar.main.js.map +1 -0
- package/dist/HebrewCalendar.mjs +144 -0
- package/dist/HebrewCalendar.module.js +144 -0
- package/dist/HebrewCalendar.module.js.map +1 -0
- package/dist/IndianCalendar.main.js +107 -0
- package/dist/IndianCalendar.main.js.map +1 -0
- package/dist/IndianCalendar.mjs +102 -0
- package/dist/IndianCalendar.module.js +102 -0
- package/dist/IndianCalendar.module.js.map +1 -0
- package/dist/IslamicCalendar.main.js +164 -0
- package/dist/IslamicCalendar.main.js.map +1 -0
- package/dist/IslamicCalendar.mjs +157 -0
- package/dist/IslamicCalendar.module.js +157 -0
- package/dist/IslamicCalendar.module.js.map +1 -0
- package/dist/JapaneseCalendar.main.js +180 -0
- package/dist/JapaneseCalendar.main.js.map +1 -0
- package/dist/JapaneseCalendar.mjs +175 -0
- package/dist/JapaneseCalendar.module.js +175 -0
- package/dist/JapaneseCalendar.module.js.map +1 -0
- package/dist/PersianCalendar.main.js +81 -0
- package/dist/PersianCalendar.main.js.map +1 -0
- package/dist/PersianCalendar.mjs +76 -0
- package/dist/PersianCalendar.module.js +76 -0
- package/dist/PersianCalendar.module.js.map +1 -0
- package/dist/TaiwanCalendar.main.js +81 -0
- package/dist/TaiwanCalendar.main.js.map +1 -0
- package/dist/TaiwanCalendar.mjs +76 -0
- package/dist/TaiwanCalendar.module.js +76 -0
- package/dist/TaiwanCalendar.module.js.map +1 -0
- package/dist/conversion.main.js +236 -0
- package/dist/conversion.main.js.map +1 -0
- package/dist/conversion.mjs +218 -0
- package/dist/conversion.module.js +218 -0
- package/dist/conversion.module.js.map +1 -0
- package/dist/createCalendar.main.js +69 -0
- package/dist/createCalendar.main.js.map +1 -0
- package/dist/createCalendar.mjs +64 -0
- package/dist/createCalendar.module.js +64 -0
- package/dist/createCalendar.module.js.map +1 -0
- package/dist/import.mjs +15 -2534
- package/dist/main.js +75 -2594
- package/dist/main.js.map +1 -1
- package/dist/manipulation.main.js +362 -0
- package/dist/manipulation.main.js.map +1 -0
- package/dist/manipulation.mjs +344 -0
- package/dist/manipulation.module.js +344 -0
- package/dist/manipulation.module.js.map +1 -0
- package/dist/module.js +15 -2534
- package/dist/module.js.map +1 -1
- package/dist/queries.main.js +287 -0
- package/dist/queries.main.js.map +1 -0
- package/dist/queries.mjs +256 -0
- package/dist/queries.module.js +256 -0
- package/dist/queries.module.js.map +1 -0
- package/dist/string.main.js +171 -0
- package/dist/string.main.js.map +1 -0
- package/dist/string.mjs +156 -0
- package/dist/string.module.js +156 -0
- package/dist/string.module.js.map +1 -0
- package/dist/utils.main.js +33 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +28 -0
- package/dist/utils.module.js +28 -0
- package/dist/utils.module.js.map +1 -0
- package/dist/weekStartData.main.js +118 -0
- package/dist/weekStartData.main.js.map +1 -0
- package/dist/weekStartData.mjs +113 -0
- package/dist/weekStartData.module.js +113 -0
- package/dist/weekStartData.module.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import {CalendarDate as $35ea8db9cb2ccb90$export$99faa760c7908e4f} from "./CalendarDate.module.js";
|
|
2
|
+
import {mod as $2b4dce13dd5a17fa$export$842a2cf37af977e1} from "./utils.module.js";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ // Portions of the code in this file are based on code from ICU.
|
|
15
|
+
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const $3b62074eb05584b2$var$EPOCH = 1721426; // 001/01/03 Julian C.E.
|
|
19
|
+
function $3b62074eb05584b2$export$f297eb839006d339(era, year, month, day) {
|
|
20
|
+
year = $3b62074eb05584b2$export$c36e0ecb2d4fa69d(era, year);
|
|
21
|
+
let y1 = year - 1;
|
|
22
|
+
let monthOffset = -2;
|
|
23
|
+
if (month <= 2) monthOffset = 0;
|
|
24
|
+
else if ($3b62074eb05584b2$export$553d7fa8e3805fc0(year)) monthOffset = -1;
|
|
25
|
+
return $3b62074eb05584b2$var$EPOCH - 1 + 365 * y1 + Math.floor(y1 / 4) - Math.floor(y1 / 100) + Math.floor(y1 / 400) + Math.floor((367 * month - 362) / 12 + monthOffset + day);
|
|
26
|
+
}
|
|
27
|
+
function $3b62074eb05584b2$export$553d7fa8e3805fc0(year) {
|
|
28
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
29
|
+
}
|
|
30
|
+
function $3b62074eb05584b2$export$c36e0ecb2d4fa69d(era, year) {
|
|
31
|
+
return era === "BC" ? 1 - year : year;
|
|
32
|
+
}
|
|
33
|
+
function $3b62074eb05584b2$export$4475b7e617eb123c(year) {
|
|
34
|
+
let era = "AD";
|
|
35
|
+
if (year <= 0) {
|
|
36
|
+
era = "BC";
|
|
37
|
+
year = 1 - year;
|
|
38
|
+
}
|
|
39
|
+
return [
|
|
40
|
+
era,
|
|
41
|
+
year
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
const $3b62074eb05584b2$var$daysInMonth = {
|
|
45
|
+
standard: [
|
|
46
|
+
31,
|
|
47
|
+
28,
|
|
48
|
+
31,
|
|
49
|
+
30,
|
|
50
|
+
31,
|
|
51
|
+
30,
|
|
52
|
+
31,
|
|
53
|
+
31,
|
|
54
|
+
30,
|
|
55
|
+
31,
|
|
56
|
+
30,
|
|
57
|
+
31
|
|
58
|
+
],
|
|
59
|
+
leapyear: [
|
|
60
|
+
31,
|
|
61
|
+
29,
|
|
62
|
+
31,
|
|
63
|
+
30,
|
|
64
|
+
31,
|
|
65
|
+
30,
|
|
66
|
+
31,
|
|
67
|
+
31,
|
|
68
|
+
30,
|
|
69
|
+
31,
|
|
70
|
+
30,
|
|
71
|
+
31
|
|
72
|
+
]
|
|
73
|
+
};
|
|
74
|
+
class $3b62074eb05584b2$export$80ee6245ec4f29ec {
|
|
75
|
+
fromJulianDay(jd) {
|
|
76
|
+
let jd0 = jd;
|
|
77
|
+
let depoch = jd0 - $3b62074eb05584b2$var$EPOCH;
|
|
78
|
+
let quadricent = Math.floor(depoch / 146097);
|
|
79
|
+
let dqc = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(depoch, 146097);
|
|
80
|
+
let cent = Math.floor(dqc / 36524);
|
|
81
|
+
let dcent = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(dqc, 36524);
|
|
82
|
+
let quad = Math.floor(dcent / 1461);
|
|
83
|
+
let dquad = (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(dcent, 1461);
|
|
84
|
+
let yindex = Math.floor(dquad / 365);
|
|
85
|
+
let extendedYear = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);
|
|
86
|
+
let [era, year] = $3b62074eb05584b2$export$4475b7e617eb123c(extendedYear);
|
|
87
|
+
let yearDay = jd0 - $3b62074eb05584b2$export$f297eb839006d339(era, year, 1, 1);
|
|
88
|
+
let leapAdj = 2;
|
|
89
|
+
if (jd0 < $3b62074eb05584b2$export$f297eb839006d339(era, year, 3, 1)) leapAdj = 0;
|
|
90
|
+
else if ($3b62074eb05584b2$export$553d7fa8e3805fc0(year)) leapAdj = 1;
|
|
91
|
+
let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367);
|
|
92
|
+
let day = jd0 - $3b62074eb05584b2$export$f297eb839006d339(era, year, month, 1) + 1;
|
|
93
|
+
return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(era, year, month, day);
|
|
94
|
+
}
|
|
95
|
+
toJulianDay(date) {
|
|
96
|
+
return $3b62074eb05584b2$export$f297eb839006d339(date.era, date.year, date.month, date.day);
|
|
97
|
+
}
|
|
98
|
+
getDaysInMonth(date) {
|
|
99
|
+
return $3b62074eb05584b2$var$daysInMonth[$3b62074eb05584b2$export$553d7fa8e3805fc0(date.year) ? "leapyear" : "standard"][date.month - 1];
|
|
100
|
+
}
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
102
|
+
getMonthsInYear(date) {
|
|
103
|
+
return 12;
|
|
104
|
+
}
|
|
105
|
+
getDaysInYear(date) {
|
|
106
|
+
return $3b62074eb05584b2$export$553d7fa8e3805fc0(date.year) ? 366 : 365;
|
|
107
|
+
}
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
109
|
+
getYearsInEra(date) {
|
|
110
|
+
return 9999;
|
|
111
|
+
}
|
|
112
|
+
getEras() {
|
|
113
|
+
return [
|
|
114
|
+
"BC",
|
|
115
|
+
"AD"
|
|
116
|
+
];
|
|
117
|
+
}
|
|
118
|
+
isInverseEra(date) {
|
|
119
|
+
return date.era === "BC";
|
|
120
|
+
}
|
|
121
|
+
balanceDate(date) {
|
|
122
|
+
if (date.year <= 0) {
|
|
123
|
+
date.era = date.era === "BC" ? "AD" : "BC";
|
|
124
|
+
date.year = 1 - date.year;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
constructor(){
|
|
128
|
+
this.identifier = "gregory";
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
export {$3b62074eb05584b2$export$f297eb839006d339 as gregorianToJulianDay, $3b62074eb05584b2$export$c36e0ecb2d4fa69d as getExtendedYear, $3b62074eb05584b2$export$553d7fa8e3805fc0 as isLeapYear, $3b62074eb05584b2$export$4475b7e617eb123c as fromExtendedYear, $3b62074eb05584b2$export$80ee6245ec4f29ec as GregorianCalendar};
|
|
134
|
+
//# sourceMappingURL=GregorianCalendar.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,8BAAQ,SAAS,wBAAwB;AACxC,SAAS,0CAAqB,GAAW,EAAE,IAAY,EAAE,KAAa,EAAE,GAAW;IACxF,OAAO,0CAAgB,KAAK;IAE5B,IAAI,KAAK,OAAO;IAChB,IAAI,cAAc;IAClB,IAAI,SAAS,GACX,cA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ars/GregorianCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod, Mutable} from '../utils';\n\nconst EPOCH = 1721426; // 001/01/03 Julian C.E.\nexport function gregorianToJulianDay(era: string, year: number, month: number, day: number): number {\n year = getExtendedYear(era, year);\n\n let y1 = year - 1;\n let monthOffset = -2;\n if (month <= 2) {\n monthOffset = 0;\n } else if (isLeapYear(year)) {\n monthOffset = -1;\n }\n\n return (\n EPOCH -\n 1 +\n 365 * y1 +\n Math.floor(y1 / 4) -\n Math.floor(y1 / 100) +\n Math.floor(y1 / 400) +\n Math.floor((367 * month - 362) / 12 + monthOffset + day)\n );\n}\n\nexport function isLeapYear(year: number): boolean {\n return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n}\n\nexport function getExtendedYear(era: string, year: number): number {\n return era === 'BC' ? 1 - year : year;\n}\n\nexport function fromExtendedYear(year: number): [string, number] {\n let era = 'AD';\n if (year <= 0) {\n era = 'BC';\n year = 1 - year;\n }\n\n return [era, year];\n}\n\nconst daysInMonth = {\n standard: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],\n leapyear: [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n};\n\n/**\n * The Gregorian calendar is the most commonly used calendar system in the world. It supports two eras: BC, and AD.\n * Years always contain 12 months, and 365 or 366 days depending on whether it is a leap year.\n */\nexport class GregorianCalendar implements Calendar {\n identifier = 'gregory';\n\n fromJulianDay(jd: number): CalendarDate {\n let jd0 = jd;\n let depoch = jd0 - EPOCH;\n let quadricent = Math.floor(depoch / 146097);\n let dqc = mod(depoch, 146097);\n let cent = Math.floor(dqc / 36524);\n let dcent = mod(dqc, 36524);\n let quad = Math.floor(dcent / 1461);\n let dquad = mod(dcent, 1461);\n let yindex = Math.floor(dquad / 365);\n\n let extendedYear = quadricent * 400 + cent * 100 + quad * 4 + yindex + (cent !== 4 && yindex !== 4 ? 1 : 0);\n let [era, year] = fromExtendedYear(extendedYear);\n let yearDay = jd0 - gregorianToJulianDay(era, year, 1, 1);\n let leapAdj = 2;\n if (jd0 < gregorianToJulianDay(era, year, 3, 1)) {\n leapAdj = 0;\n } else if (isLeapYear(year)) {\n leapAdj = 1;\n }\n let month = Math.floor(((yearDay + leapAdj) * 12 + 373) / 367);\n let day = jd0 - gregorianToJulianDay(era, year, month, 1) + 1;\n\n return new CalendarDate(era, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate): number {\n return gregorianToJulianDay(date.era, date.year, date.month, date.day);\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return daysInMonth[isLeapYear(date.year) ? 'leapyear' : 'standard'][date.month - 1];\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getMonthsInYear(date: AnyCalendarDate): number {\n return 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 366 : 365;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getYearsInEra(date: AnyCalendarDate): number {\n return 9999;\n }\n\n getEras() {\n return ['BC', 'AD'];\n }\n\n isInverseEra(date: AnyCalendarDate): boolean {\n return date.era === 'BC';\n }\n\n balanceDate(date: Mutable<AnyCalendarDate>) {\n if (date.year <= 0) {\n date.era = date.era === 'BC' ? 'AD' : 'BC';\n date.year = 1 - date.year;\n }\n }\n}\n"],"names":[],"version":3,"file":"GregorianCalendar.module.js.map"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
var $625ad1e1f4c43bc1$exports = require("./CalendarDate.main.js");
|
|
2
|
+
var $a5090d6430502238$exports = require("./utils.main.js");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "HebrewCalendar", () => $0f5324ee3bdd9396$export$ca405048b8fb5af);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/ // Portions of the code in this file are based on code from ICU.
|
|
21
|
+
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const $0f5324ee3bdd9396$var$HEBREW_EPOCH = 347997;
|
|
25
|
+
// Hebrew date calculations are performed in terms of days, hours, and
|
|
26
|
+
// "parts" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.
|
|
27
|
+
const $0f5324ee3bdd9396$var$HOUR_PARTS = 1080;
|
|
28
|
+
const $0f5324ee3bdd9396$var$DAY_PARTS = 24 * $0f5324ee3bdd9396$var$HOUR_PARTS;
|
|
29
|
+
// An approximate value for the length of a lunar month.
|
|
30
|
+
// It is used to calculate the approximate year and month of a given
|
|
31
|
+
// absolute date.
|
|
32
|
+
const $0f5324ee3bdd9396$var$MONTH_DAYS = 29;
|
|
33
|
+
const $0f5324ee3bdd9396$var$MONTH_FRACT = 12 * $0f5324ee3bdd9396$var$HOUR_PARTS + 793;
|
|
34
|
+
const $0f5324ee3bdd9396$var$MONTH_PARTS = $0f5324ee3bdd9396$var$MONTH_DAYS * $0f5324ee3bdd9396$var$DAY_PARTS + $0f5324ee3bdd9396$var$MONTH_FRACT;
|
|
35
|
+
function $0f5324ee3bdd9396$var$isLeapYear(year) {
|
|
36
|
+
return (0, $a5090d6430502238$exports.mod)(year * 7 + 1, 19) < 7;
|
|
37
|
+
}
|
|
38
|
+
// Test for delay of start of new year and to avoid
|
|
39
|
+
// Sunday, Wednesday, and Friday as start of the new year.
|
|
40
|
+
function $0f5324ee3bdd9396$var$hebrewDelay1(year) {
|
|
41
|
+
let months = Math.floor((235 * year - 234) / 19);
|
|
42
|
+
let parts = 12084 + 13753 * months;
|
|
43
|
+
let day = months * 29 + Math.floor(parts / 25920);
|
|
44
|
+
if ((0, $a5090d6430502238$exports.mod)(3 * (day + 1), 7) < 3) day += 1;
|
|
45
|
+
return day;
|
|
46
|
+
}
|
|
47
|
+
// Check for delay in start of new year due to length of adjacent years
|
|
48
|
+
function $0f5324ee3bdd9396$var$hebrewDelay2(year) {
|
|
49
|
+
let last = $0f5324ee3bdd9396$var$hebrewDelay1(year - 1);
|
|
50
|
+
let present = $0f5324ee3bdd9396$var$hebrewDelay1(year);
|
|
51
|
+
let next = $0f5324ee3bdd9396$var$hebrewDelay1(year + 1);
|
|
52
|
+
if (next - present === 356) return 2;
|
|
53
|
+
if (present - last === 382) return 1;
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
function $0f5324ee3bdd9396$var$startOfYear(year) {
|
|
57
|
+
return $0f5324ee3bdd9396$var$hebrewDelay1(year) + $0f5324ee3bdd9396$var$hebrewDelay2(year);
|
|
58
|
+
}
|
|
59
|
+
function $0f5324ee3bdd9396$var$getDaysInYear(year) {
|
|
60
|
+
return $0f5324ee3bdd9396$var$startOfYear(year + 1) - $0f5324ee3bdd9396$var$startOfYear(year);
|
|
61
|
+
}
|
|
62
|
+
function $0f5324ee3bdd9396$var$getYearType(year) {
|
|
63
|
+
let yearLength = $0f5324ee3bdd9396$var$getDaysInYear(year);
|
|
64
|
+
if (yearLength > 380) yearLength -= 30; // Subtract length of leap month.
|
|
65
|
+
switch(yearLength){
|
|
66
|
+
case 353:
|
|
67
|
+
return 0; // deficient
|
|
68
|
+
case 354:
|
|
69
|
+
return 1; // normal
|
|
70
|
+
case 355:
|
|
71
|
+
return 2; // complete
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function $0f5324ee3bdd9396$var$getDaysInMonth(year, month) {
|
|
75
|
+
// Normalize month numbers from 1 - 13, even on non-leap years
|
|
76
|
+
if (month >= 6 && !$0f5324ee3bdd9396$var$isLeapYear(year)) month++;
|
|
77
|
+
// First of all, dispose of fixed-length 29 day months
|
|
78
|
+
if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) return 29;
|
|
79
|
+
let yearType = $0f5324ee3bdd9396$var$getYearType(year);
|
|
80
|
+
// If it's Heshvan, days depend on length of year
|
|
81
|
+
if (month === 2) return yearType === 2 ? 30 : 29;
|
|
82
|
+
// Similarly, Kislev varies with the length of year
|
|
83
|
+
if (month === 3) return yearType === 0 ? 29 : 30;
|
|
84
|
+
// Adar I only exists in leap years
|
|
85
|
+
if (month === 6) return $0f5324ee3bdd9396$var$isLeapYear(year) ? 30 : 0;
|
|
86
|
+
return 30;
|
|
87
|
+
}
|
|
88
|
+
class $0f5324ee3bdd9396$export$ca405048b8fb5af {
|
|
89
|
+
fromJulianDay(jd) {
|
|
90
|
+
let d = jd - $0f5324ee3bdd9396$var$HEBREW_EPOCH;
|
|
91
|
+
let m = d * $0f5324ee3bdd9396$var$DAY_PARTS / $0f5324ee3bdd9396$var$MONTH_PARTS; // Months (approx)
|
|
92
|
+
let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)
|
|
93
|
+
let ys = $0f5324ee3bdd9396$var$startOfYear(year); // 1st day of year
|
|
94
|
+
let dayOfYear = Math.floor(d - ys);
|
|
95
|
+
// Because of the postponement rules, it's possible to guess wrong. Fix it.
|
|
96
|
+
while(dayOfYear < 1){
|
|
97
|
+
year--;
|
|
98
|
+
ys = $0f5324ee3bdd9396$var$startOfYear(year);
|
|
99
|
+
dayOfYear = Math.floor(d - ys);
|
|
100
|
+
}
|
|
101
|
+
// Now figure out which month we're in, and the date within that month
|
|
102
|
+
let month = 1;
|
|
103
|
+
let monthStart = 0;
|
|
104
|
+
while(monthStart < dayOfYear){
|
|
105
|
+
monthStart += $0f5324ee3bdd9396$var$getDaysInMonth(year, month);
|
|
106
|
+
month++;
|
|
107
|
+
}
|
|
108
|
+
month--;
|
|
109
|
+
monthStart -= $0f5324ee3bdd9396$var$getDaysInMonth(year, month);
|
|
110
|
+
let day = dayOfYear - monthStart;
|
|
111
|
+
return new (0, $625ad1e1f4c43bc1$exports.CalendarDate)(this, year, month, day);
|
|
112
|
+
}
|
|
113
|
+
toJulianDay(date) {
|
|
114
|
+
let jd = $0f5324ee3bdd9396$var$startOfYear(date.year);
|
|
115
|
+
for(let month = 1; month < date.month; month++)jd += $0f5324ee3bdd9396$var$getDaysInMonth(date.year, month);
|
|
116
|
+
return jd + date.day + $0f5324ee3bdd9396$var$HEBREW_EPOCH;
|
|
117
|
+
}
|
|
118
|
+
getDaysInMonth(date) {
|
|
119
|
+
return $0f5324ee3bdd9396$var$getDaysInMonth(date.year, date.month);
|
|
120
|
+
}
|
|
121
|
+
getMonthsInYear(date) {
|
|
122
|
+
return $0f5324ee3bdd9396$var$isLeapYear(date.year) ? 13 : 12;
|
|
123
|
+
}
|
|
124
|
+
getDaysInYear(date) {
|
|
125
|
+
return $0f5324ee3bdd9396$var$getDaysInYear(date.year);
|
|
126
|
+
}
|
|
127
|
+
getYearsInEra() {
|
|
128
|
+
// 6239 gregorian
|
|
129
|
+
return 9999;
|
|
130
|
+
}
|
|
131
|
+
getEras() {
|
|
132
|
+
return [
|
|
133
|
+
"AM"
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
balanceYearMonth(date, previousDate) {
|
|
137
|
+
// Keep date in the same month when switching between leap years and non leap years
|
|
138
|
+
if (previousDate.year !== date.year) {
|
|
139
|
+
if ($0f5324ee3bdd9396$var$isLeapYear(previousDate.year) && !$0f5324ee3bdd9396$var$isLeapYear(date.year) && previousDate.month > 6) date.month--;
|
|
140
|
+
else if (!$0f5324ee3bdd9396$var$isLeapYear(previousDate.year) && $0f5324ee3bdd9396$var$isLeapYear(date.year) && previousDate.month > 6) date.month++;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
constructor(){
|
|
144
|
+
this.identifier = "hebrew";
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=HebrewCalendar.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,qCAAe;AAErB,sEAAsE;AACtE,uEAAuE;AACvE,MAAM,mCAAa;AACnB,MAAM,kCAAa,KAAK;AAExB,wDAAwD;AACxD,oEAAoE;AACpE,iBAAiB;AACjB,MAAM,mCAAa;AACnB,MAAM,oCAAc,KAAK,mCAAa;AACtC,MAAM,oCAAc,mCAAa,kCAAY;AAE7C,SAAS,iCAAW,IAAY;IAC9B,OAAO,CAAA,GAAA,6BAAE,EAAE,OAAO,IAAI,GAAG,MAAM;AACjC;AAEA,mDAAmD;AACnD,0DAA0D;AAC1D,SAAS,mCAAa,IAAY;IAChC,IAAI,SAAS,KAAK,KAAK,CAAC,AAAC,CAAA,MAAM,OAAO,GAAE,IAAK;IAC7C,IAAI,QAAQ,QAAQ,QAAQ;IAC5B,IAAI,MAAM,SAAS,KAAK,KAAK,KAAK,CAAC,QAAQ;IAE3C,IAAI,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iBACL,IAAI,CAAC,iCAAW,aAAa,IAAI,KAAK,iCAAW,KAAK,IAAI,KAAK,aAAa,KAAK,GAAG,GACzF,KAAK,KAAK;QAEd;IACF;;aAtEA,aAAa;;AAuEf","sources":["packages/@internationalized/date/src/calendars/HebrewCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod, Mutable} from '../utils';\n\nconst HEBREW_EPOCH = 347997;\n\n// Hebrew date calculations are performed in terms of days, hours, and\n// \"parts\" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.\nconst HOUR_PARTS = 1080;\nconst DAY_PARTS = 24 * HOUR_PARTS;\n\n// An approximate value for the length of a lunar month.\n// It is used to calculate the approximate year and month of a given\n// absolute date.\nconst MONTH_DAYS = 29;\nconst MONTH_FRACT = 12 * HOUR_PARTS + 793;\nconst MONTH_PARTS = MONTH_DAYS * DAY_PARTS + MONTH_FRACT;\n\nfunction isLeapYear(year: number) {\n return mod(year * 7 + 1, 19) < 7;\n}\n\n// Test for delay of start of new year and to avoid\n// Sunday, Wednesday, and Friday as start of the new year.\nfunction hebrewDelay1(year: number) {\n let months = Math.floor((235 * year - 234) / 19);\n let parts = 12084 + 13753 * months;\n let day = months * 29 + Math.floor(parts / 25920);\n\n if (mod(3 * (day + 1), 7) < 3) {\n day += 1;\n }\n\n return day;\n}\n\n// Check for delay in start of new year due to length of adjacent years\nfunction hebrewDelay2(year: number) {\n let last = hebrewDelay1(year - 1);\n let present = hebrewDelay1(year);\n let next = hebrewDelay1(year + 1);\n\n if (next - present === 356) {\n return 2;\n }\n\n if (present - last === 382) {\n return 1;\n }\n\n return 0;\n}\n\nfunction startOfYear(year: number) {\n return hebrewDelay1(year) + hebrewDelay2(year);\n}\n\nfunction getDaysInYear(year: number) {\n return startOfYear(year + 1) - startOfYear(year);\n}\n\nfunction getYearType(year: number) {\n let yearLength = getDaysInYear(year);\n\n if (yearLength > 380) {\n yearLength -= 30; // Subtract length of leap month.\n }\n\n switch (yearLength) {\n case 353:\n return 0; // deficient\n case 354:\n return 1; // normal\n case 355:\n return 2; // complete\n }\n}\n\nfunction getDaysInMonth(year: number, month: number): number {\n // Normalize month numbers from 1 - 13, even on non-leap years\n if (month >= 6 && !isLeapYear(year)) {\n month++;\n }\n\n // First of all, dispose of fixed-length 29 day months\n if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) {\n return 29;\n }\n\n let yearType = getYearType(year);\n\n // If it's Heshvan, days depend on length of year\n if (month === 2) {\n return yearType === 2 ? 30 : 29;\n }\n\n // Similarly, Kislev varies with the length of year\n if (month === 3) {\n return yearType === 0 ? 29 : 30;\n }\n\n // Adar I only exists in leap years\n if (month === 6) {\n return isLeapYear(year) ? 30 : 0;\n }\n\n return 30;\n}\n\n/**\n * The Hebrew calendar is used in Israel and around the world by the Jewish faith.\n * Years include either 12 or 13 months depending on whether it is a leap year.\n * In leap years, an extra month is inserted at month 6.\n */\nexport class HebrewCalendar implements Calendar {\n identifier = 'hebrew';\n\n fromJulianDay(jd: number): CalendarDate {\n let d = jd - HEBREW_EPOCH;\n let m = (d * DAY_PARTS) / MONTH_PARTS; // Months (approx)\n let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)\n let ys = startOfYear(year); // 1st day of year\n let dayOfYear = Math.floor(d - ys);\n\n // Because of the postponement rules, it's possible to guess wrong. Fix it.\n while (dayOfYear < 1) {\n year--;\n ys = startOfYear(year);\n dayOfYear = Math.floor(d - ys);\n }\n\n // Now figure out which month we're in, and the date within that month\n let month = 1;\n let monthStart = 0;\n while (monthStart < dayOfYear) {\n monthStart += getDaysInMonth(year, month);\n month++;\n }\n\n month--;\n monthStart -= getDaysInMonth(year, month);\n\n let day = dayOfYear - monthStart;\n return new CalendarDate(this, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n let jd = startOfYear(date.year);\n for (let month = 1; month < date.month; month++) {\n jd += getDaysInMonth(date.year, month);\n }\n\n return jd + date.day + HEBREW_EPOCH;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return getDaysInMonth(date.year, date.month);\n }\n\n getMonthsInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 13 : 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return getDaysInYear(date.year);\n }\n\n getYearsInEra(): number {\n // 6239 gregorian\n return 9999;\n }\n\n getEras() {\n return ['AM'];\n }\n\n balanceYearMonth(date: Mutable<AnyCalendarDate>, previousDate: AnyCalendarDate) {\n // Keep date in the same month when switching between leap years and non leap years\n if (previousDate.year !== date.year) {\n if (isLeapYear(previousDate.year) && !isLeapYear(date.year) && previousDate.month > 6) {\n date.month--;\n } else if (!isLeapYear(previousDate.year) && isLeapYear(date.year) && previousDate.month > 6) {\n date.month++;\n }\n }\n }\n}\n"],"names":[],"version":3,"file":"HebrewCalendar.main.js.map"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {CalendarDate as $35ea8db9cb2ccb90$export$99faa760c7908e4f} from "./CalendarDate.mjs";
|
|
2
|
+
import {mod as $2b4dce13dd5a17fa$export$842a2cf37af977e1} from "./utils.mjs";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ // Portions of the code in this file are based on code from ICU.
|
|
15
|
+
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const $7c5f6fbf42389787$var$HEBREW_EPOCH = 347997;
|
|
19
|
+
// Hebrew date calculations are performed in terms of days, hours, and
|
|
20
|
+
// "parts" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.
|
|
21
|
+
const $7c5f6fbf42389787$var$HOUR_PARTS = 1080;
|
|
22
|
+
const $7c5f6fbf42389787$var$DAY_PARTS = 24 * $7c5f6fbf42389787$var$HOUR_PARTS;
|
|
23
|
+
// An approximate value for the length of a lunar month.
|
|
24
|
+
// It is used to calculate the approximate year and month of a given
|
|
25
|
+
// absolute date.
|
|
26
|
+
const $7c5f6fbf42389787$var$MONTH_DAYS = 29;
|
|
27
|
+
const $7c5f6fbf42389787$var$MONTH_FRACT = 12 * $7c5f6fbf42389787$var$HOUR_PARTS + 793;
|
|
28
|
+
const $7c5f6fbf42389787$var$MONTH_PARTS = $7c5f6fbf42389787$var$MONTH_DAYS * $7c5f6fbf42389787$var$DAY_PARTS + $7c5f6fbf42389787$var$MONTH_FRACT;
|
|
29
|
+
function $7c5f6fbf42389787$var$isLeapYear(year) {
|
|
30
|
+
return (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(year * 7 + 1, 19) < 7;
|
|
31
|
+
}
|
|
32
|
+
// Test for delay of start of new year and to avoid
|
|
33
|
+
// Sunday, Wednesday, and Friday as start of the new year.
|
|
34
|
+
function $7c5f6fbf42389787$var$hebrewDelay1(year) {
|
|
35
|
+
let months = Math.floor((235 * year - 234) / 19);
|
|
36
|
+
let parts = 12084 + 13753 * months;
|
|
37
|
+
let day = months * 29 + Math.floor(parts / 25920);
|
|
38
|
+
if ((0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(3 * (day + 1), 7) < 3) day += 1;
|
|
39
|
+
return day;
|
|
40
|
+
}
|
|
41
|
+
// Check for delay in start of new year due to length of adjacent years
|
|
42
|
+
function $7c5f6fbf42389787$var$hebrewDelay2(year) {
|
|
43
|
+
let last = $7c5f6fbf42389787$var$hebrewDelay1(year - 1);
|
|
44
|
+
let present = $7c5f6fbf42389787$var$hebrewDelay1(year);
|
|
45
|
+
let next = $7c5f6fbf42389787$var$hebrewDelay1(year + 1);
|
|
46
|
+
if (next - present === 356) return 2;
|
|
47
|
+
if (present - last === 382) return 1;
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
function $7c5f6fbf42389787$var$startOfYear(year) {
|
|
51
|
+
return $7c5f6fbf42389787$var$hebrewDelay1(year) + $7c5f6fbf42389787$var$hebrewDelay2(year);
|
|
52
|
+
}
|
|
53
|
+
function $7c5f6fbf42389787$var$getDaysInYear(year) {
|
|
54
|
+
return $7c5f6fbf42389787$var$startOfYear(year + 1) - $7c5f6fbf42389787$var$startOfYear(year);
|
|
55
|
+
}
|
|
56
|
+
function $7c5f6fbf42389787$var$getYearType(year) {
|
|
57
|
+
let yearLength = $7c5f6fbf42389787$var$getDaysInYear(year);
|
|
58
|
+
if (yearLength > 380) yearLength -= 30; // Subtract length of leap month.
|
|
59
|
+
switch(yearLength){
|
|
60
|
+
case 353:
|
|
61
|
+
return 0; // deficient
|
|
62
|
+
case 354:
|
|
63
|
+
return 1; // normal
|
|
64
|
+
case 355:
|
|
65
|
+
return 2; // complete
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function $7c5f6fbf42389787$var$getDaysInMonth(year, month) {
|
|
69
|
+
// Normalize month numbers from 1 - 13, even on non-leap years
|
|
70
|
+
if (month >= 6 && !$7c5f6fbf42389787$var$isLeapYear(year)) month++;
|
|
71
|
+
// First of all, dispose of fixed-length 29 day months
|
|
72
|
+
if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) return 29;
|
|
73
|
+
let yearType = $7c5f6fbf42389787$var$getYearType(year);
|
|
74
|
+
// If it's Heshvan, days depend on length of year
|
|
75
|
+
if (month === 2) return yearType === 2 ? 30 : 29;
|
|
76
|
+
// Similarly, Kislev varies with the length of year
|
|
77
|
+
if (month === 3) return yearType === 0 ? 29 : 30;
|
|
78
|
+
// Adar I only exists in leap years
|
|
79
|
+
if (month === 6) return $7c5f6fbf42389787$var$isLeapYear(year) ? 30 : 0;
|
|
80
|
+
return 30;
|
|
81
|
+
}
|
|
82
|
+
class $7c5f6fbf42389787$export$ca405048b8fb5af {
|
|
83
|
+
fromJulianDay(jd) {
|
|
84
|
+
let d = jd - $7c5f6fbf42389787$var$HEBREW_EPOCH;
|
|
85
|
+
let m = d * $7c5f6fbf42389787$var$DAY_PARTS / $7c5f6fbf42389787$var$MONTH_PARTS; // Months (approx)
|
|
86
|
+
let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)
|
|
87
|
+
let ys = $7c5f6fbf42389787$var$startOfYear(year); // 1st day of year
|
|
88
|
+
let dayOfYear = Math.floor(d - ys);
|
|
89
|
+
// Because of the postponement rules, it's possible to guess wrong. Fix it.
|
|
90
|
+
while(dayOfYear < 1){
|
|
91
|
+
year--;
|
|
92
|
+
ys = $7c5f6fbf42389787$var$startOfYear(year);
|
|
93
|
+
dayOfYear = Math.floor(d - ys);
|
|
94
|
+
}
|
|
95
|
+
// Now figure out which month we're in, and the date within that month
|
|
96
|
+
let month = 1;
|
|
97
|
+
let monthStart = 0;
|
|
98
|
+
while(monthStart < dayOfYear){
|
|
99
|
+
monthStart += $7c5f6fbf42389787$var$getDaysInMonth(year, month);
|
|
100
|
+
month++;
|
|
101
|
+
}
|
|
102
|
+
month--;
|
|
103
|
+
monthStart -= $7c5f6fbf42389787$var$getDaysInMonth(year, month);
|
|
104
|
+
let day = dayOfYear - monthStart;
|
|
105
|
+
return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(this, year, month, day);
|
|
106
|
+
}
|
|
107
|
+
toJulianDay(date) {
|
|
108
|
+
let jd = $7c5f6fbf42389787$var$startOfYear(date.year);
|
|
109
|
+
for(let month = 1; month < date.month; month++)jd += $7c5f6fbf42389787$var$getDaysInMonth(date.year, month);
|
|
110
|
+
return jd + date.day + $7c5f6fbf42389787$var$HEBREW_EPOCH;
|
|
111
|
+
}
|
|
112
|
+
getDaysInMonth(date) {
|
|
113
|
+
return $7c5f6fbf42389787$var$getDaysInMonth(date.year, date.month);
|
|
114
|
+
}
|
|
115
|
+
getMonthsInYear(date) {
|
|
116
|
+
return $7c5f6fbf42389787$var$isLeapYear(date.year) ? 13 : 12;
|
|
117
|
+
}
|
|
118
|
+
getDaysInYear(date) {
|
|
119
|
+
return $7c5f6fbf42389787$var$getDaysInYear(date.year);
|
|
120
|
+
}
|
|
121
|
+
getYearsInEra() {
|
|
122
|
+
// 6239 gregorian
|
|
123
|
+
return 9999;
|
|
124
|
+
}
|
|
125
|
+
getEras() {
|
|
126
|
+
return [
|
|
127
|
+
"AM"
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
balanceYearMonth(date, previousDate) {
|
|
131
|
+
// Keep date in the same month when switching between leap years and non leap years
|
|
132
|
+
if (previousDate.year !== date.year) {
|
|
133
|
+
if ($7c5f6fbf42389787$var$isLeapYear(previousDate.year) && !$7c5f6fbf42389787$var$isLeapYear(date.year) && previousDate.month > 6) date.month--;
|
|
134
|
+
else if (!$7c5f6fbf42389787$var$isLeapYear(previousDate.year) && $7c5f6fbf42389787$var$isLeapYear(date.year) && previousDate.month > 6) date.month++;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
constructor(){
|
|
138
|
+
this.identifier = "hebrew";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
export {$7c5f6fbf42389787$export$ca405048b8fb5af as HebrewCalendar};
|
|
144
|
+
//# sourceMappingURL=HebrewCalendar.mjs.map
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {CalendarDate as $35ea8db9cb2ccb90$export$99faa760c7908e4f} from "./CalendarDate.module.js";
|
|
2
|
+
import {mod as $2b4dce13dd5a17fa$export$842a2cf37af977e1} from "./utils.module.js";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ // Portions of the code in this file are based on code from ICU.
|
|
15
|
+
// Original licensing can be found in the NOTICE file in the root directory of this source tree.
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const $7c5f6fbf42389787$var$HEBREW_EPOCH = 347997;
|
|
19
|
+
// Hebrew date calculations are performed in terms of days, hours, and
|
|
20
|
+
// "parts" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.
|
|
21
|
+
const $7c5f6fbf42389787$var$HOUR_PARTS = 1080;
|
|
22
|
+
const $7c5f6fbf42389787$var$DAY_PARTS = 24 * $7c5f6fbf42389787$var$HOUR_PARTS;
|
|
23
|
+
// An approximate value for the length of a lunar month.
|
|
24
|
+
// It is used to calculate the approximate year and month of a given
|
|
25
|
+
// absolute date.
|
|
26
|
+
const $7c5f6fbf42389787$var$MONTH_DAYS = 29;
|
|
27
|
+
const $7c5f6fbf42389787$var$MONTH_FRACT = 12 * $7c5f6fbf42389787$var$HOUR_PARTS + 793;
|
|
28
|
+
const $7c5f6fbf42389787$var$MONTH_PARTS = $7c5f6fbf42389787$var$MONTH_DAYS * $7c5f6fbf42389787$var$DAY_PARTS + $7c5f6fbf42389787$var$MONTH_FRACT;
|
|
29
|
+
function $7c5f6fbf42389787$var$isLeapYear(year) {
|
|
30
|
+
return (0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(year * 7 + 1, 19) < 7;
|
|
31
|
+
}
|
|
32
|
+
// Test for delay of start of new year and to avoid
|
|
33
|
+
// Sunday, Wednesday, and Friday as start of the new year.
|
|
34
|
+
function $7c5f6fbf42389787$var$hebrewDelay1(year) {
|
|
35
|
+
let months = Math.floor((235 * year - 234) / 19);
|
|
36
|
+
let parts = 12084 + 13753 * months;
|
|
37
|
+
let day = months * 29 + Math.floor(parts / 25920);
|
|
38
|
+
if ((0, $2b4dce13dd5a17fa$export$842a2cf37af977e1)(3 * (day + 1), 7) < 3) day += 1;
|
|
39
|
+
return day;
|
|
40
|
+
}
|
|
41
|
+
// Check for delay in start of new year due to length of adjacent years
|
|
42
|
+
function $7c5f6fbf42389787$var$hebrewDelay2(year) {
|
|
43
|
+
let last = $7c5f6fbf42389787$var$hebrewDelay1(year - 1);
|
|
44
|
+
let present = $7c5f6fbf42389787$var$hebrewDelay1(year);
|
|
45
|
+
let next = $7c5f6fbf42389787$var$hebrewDelay1(year + 1);
|
|
46
|
+
if (next - present === 356) return 2;
|
|
47
|
+
if (present - last === 382) return 1;
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
function $7c5f6fbf42389787$var$startOfYear(year) {
|
|
51
|
+
return $7c5f6fbf42389787$var$hebrewDelay1(year) + $7c5f6fbf42389787$var$hebrewDelay2(year);
|
|
52
|
+
}
|
|
53
|
+
function $7c5f6fbf42389787$var$getDaysInYear(year) {
|
|
54
|
+
return $7c5f6fbf42389787$var$startOfYear(year + 1) - $7c5f6fbf42389787$var$startOfYear(year);
|
|
55
|
+
}
|
|
56
|
+
function $7c5f6fbf42389787$var$getYearType(year) {
|
|
57
|
+
let yearLength = $7c5f6fbf42389787$var$getDaysInYear(year);
|
|
58
|
+
if (yearLength > 380) yearLength -= 30; // Subtract length of leap month.
|
|
59
|
+
switch(yearLength){
|
|
60
|
+
case 353:
|
|
61
|
+
return 0; // deficient
|
|
62
|
+
case 354:
|
|
63
|
+
return 1; // normal
|
|
64
|
+
case 355:
|
|
65
|
+
return 2; // complete
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function $7c5f6fbf42389787$var$getDaysInMonth(year, month) {
|
|
69
|
+
// Normalize month numbers from 1 - 13, even on non-leap years
|
|
70
|
+
if (month >= 6 && !$7c5f6fbf42389787$var$isLeapYear(year)) month++;
|
|
71
|
+
// First of all, dispose of fixed-length 29 day months
|
|
72
|
+
if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) return 29;
|
|
73
|
+
let yearType = $7c5f6fbf42389787$var$getYearType(year);
|
|
74
|
+
// If it's Heshvan, days depend on length of year
|
|
75
|
+
if (month === 2) return yearType === 2 ? 30 : 29;
|
|
76
|
+
// Similarly, Kislev varies with the length of year
|
|
77
|
+
if (month === 3) return yearType === 0 ? 29 : 30;
|
|
78
|
+
// Adar I only exists in leap years
|
|
79
|
+
if (month === 6) return $7c5f6fbf42389787$var$isLeapYear(year) ? 30 : 0;
|
|
80
|
+
return 30;
|
|
81
|
+
}
|
|
82
|
+
class $7c5f6fbf42389787$export$ca405048b8fb5af {
|
|
83
|
+
fromJulianDay(jd) {
|
|
84
|
+
let d = jd - $7c5f6fbf42389787$var$HEBREW_EPOCH;
|
|
85
|
+
let m = d * $7c5f6fbf42389787$var$DAY_PARTS / $7c5f6fbf42389787$var$MONTH_PARTS; // Months (approx)
|
|
86
|
+
let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)
|
|
87
|
+
let ys = $7c5f6fbf42389787$var$startOfYear(year); // 1st day of year
|
|
88
|
+
let dayOfYear = Math.floor(d - ys);
|
|
89
|
+
// Because of the postponement rules, it's possible to guess wrong. Fix it.
|
|
90
|
+
while(dayOfYear < 1){
|
|
91
|
+
year--;
|
|
92
|
+
ys = $7c5f6fbf42389787$var$startOfYear(year);
|
|
93
|
+
dayOfYear = Math.floor(d - ys);
|
|
94
|
+
}
|
|
95
|
+
// Now figure out which month we're in, and the date within that month
|
|
96
|
+
let month = 1;
|
|
97
|
+
let monthStart = 0;
|
|
98
|
+
while(monthStart < dayOfYear){
|
|
99
|
+
monthStart += $7c5f6fbf42389787$var$getDaysInMonth(year, month);
|
|
100
|
+
month++;
|
|
101
|
+
}
|
|
102
|
+
month--;
|
|
103
|
+
monthStart -= $7c5f6fbf42389787$var$getDaysInMonth(year, month);
|
|
104
|
+
let day = dayOfYear - monthStart;
|
|
105
|
+
return new (0, $35ea8db9cb2ccb90$export$99faa760c7908e4f)(this, year, month, day);
|
|
106
|
+
}
|
|
107
|
+
toJulianDay(date) {
|
|
108
|
+
let jd = $7c5f6fbf42389787$var$startOfYear(date.year);
|
|
109
|
+
for(let month = 1; month < date.month; month++)jd += $7c5f6fbf42389787$var$getDaysInMonth(date.year, month);
|
|
110
|
+
return jd + date.day + $7c5f6fbf42389787$var$HEBREW_EPOCH;
|
|
111
|
+
}
|
|
112
|
+
getDaysInMonth(date) {
|
|
113
|
+
return $7c5f6fbf42389787$var$getDaysInMonth(date.year, date.month);
|
|
114
|
+
}
|
|
115
|
+
getMonthsInYear(date) {
|
|
116
|
+
return $7c5f6fbf42389787$var$isLeapYear(date.year) ? 13 : 12;
|
|
117
|
+
}
|
|
118
|
+
getDaysInYear(date) {
|
|
119
|
+
return $7c5f6fbf42389787$var$getDaysInYear(date.year);
|
|
120
|
+
}
|
|
121
|
+
getYearsInEra() {
|
|
122
|
+
// 6239 gregorian
|
|
123
|
+
return 9999;
|
|
124
|
+
}
|
|
125
|
+
getEras() {
|
|
126
|
+
return [
|
|
127
|
+
"AM"
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
balanceYearMonth(date, previousDate) {
|
|
131
|
+
// Keep date in the same month when switching between leap years and non leap years
|
|
132
|
+
if (previousDate.year !== date.year) {
|
|
133
|
+
if ($7c5f6fbf42389787$var$isLeapYear(previousDate.year) && !$7c5f6fbf42389787$var$isLeapYear(date.year) && previousDate.month > 6) date.month--;
|
|
134
|
+
else if (!$7c5f6fbf42389787$var$isLeapYear(previousDate.year) && $7c5f6fbf42389787$var$isLeapYear(date.year) && previousDate.month > 6) date.month++;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
constructor(){
|
|
138
|
+
this.identifier = "hebrew";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
export {$7c5f6fbf42389787$export$ca405048b8fb5af as HebrewCalendar};
|
|
144
|
+
//# sourceMappingURL=HebrewCalendar.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,gEAAgE;AAChE,gGAAgG;;;AAMhG,MAAM,qCAAe;AAErB,sEAAsE;AACtE,uEAAuE;AACvE,MAAM,mCAAa;AACnB,MAAM,kCAAa,KAAK;AAExB,wDAAwD;AACxD,oEAAoE;AACpE,iBAAiB;AACjB,MAAM,mCAAa;AACnB,MAAM,oCAAc,KAAK,mCAAa;AACtC,MAAM,oCAAc,mCAAa,kCAAY;AAE7C,SAAS,iCAAW,IAAY;IAC9B,OAAO,CAAA,GAAA,yCAAE,EAAE,OAAO,IAAI,GAAG,MAAM;AACjC;AAEA,mDAAmD;AACnD,0DAA0D;AAC1D,SAAS,mCAAa,IAAY;IAChC,IAAI,SAAS,KAAK,KAAK,CAAC,AAAC,CAAA,MAAM,OAAO,GAAE,IAAK;IAC7C,IAAI,QAAQ,QAAQ,QAAQ;IAC5B,IAAI,MAAM,SAAS,KAAK,KAAK,KAAK,CAAC,QAAQ;IAE3C,IAAI,CAAA,GAAA,yCAAE,EAAE,IAAK,CAAA,MAAM,C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CAAW,KAAK,IAAI,KAAK,aAAa,KAAK,GAAG,GACzF,KAAK,KAAK;QAEd;IACF;;aAtEA,aAAa;;AAuEf","sources":["packages/@internationalized/date/src/calendars/HebrewCalendar.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from ICU.\n// Original licensing can be found in the NOTICE file in the root directory of this source tree.\n\nimport {AnyCalendarDate, Calendar} from '../types';\nimport {CalendarDate} from '../CalendarDate';\nimport {mod, Mutable} from '../utils';\n\nconst HEBREW_EPOCH = 347997;\n\n// Hebrew date calculations are performed in terms of days, hours, and\n// \"parts\" (or halakim), which are 1/1080 of an hour, or 3 1/3 seconds.\nconst HOUR_PARTS = 1080;\nconst DAY_PARTS = 24 * HOUR_PARTS;\n\n// An approximate value for the length of a lunar month.\n// It is used to calculate the approximate year and month of a given\n// absolute date.\nconst MONTH_DAYS = 29;\nconst MONTH_FRACT = 12 * HOUR_PARTS + 793;\nconst MONTH_PARTS = MONTH_DAYS * DAY_PARTS + MONTH_FRACT;\n\nfunction isLeapYear(year: number) {\n return mod(year * 7 + 1, 19) < 7;\n}\n\n// Test for delay of start of new year and to avoid\n// Sunday, Wednesday, and Friday as start of the new year.\nfunction hebrewDelay1(year: number) {\n let months = Math.floor((235 * year - 234) / 19);\n let parts = 12084 + 13753 * months;\n let day = months * 29 + Math.floor(parts / 25920);\n\n if (mod(3 * (day + 1), 7) < 3) {\n day += 1;\n }\n\n return day;\n}\n\n// Check for delay in start of new year due to length of adjacent years\nfunction hebrewDelay2(year: number) {\n let last = hebrewDelay1(year - 1);\n let present = hebrewDelay1(year);\n let next = hebrewDelay1(year + 1);\n\n if (next - present === 356) {\n return 2;\n }\n\n if (present - last === 382) {\n return 1;\n }\n\n return 0;\n}\n\nfunction startOfYear(year: number) {\n return hebrewDelay1(year) + hebrewDelay2(year);\n}\n\nfunction getDaysInYear(year: number) {\n return startOfYear(year + 1) - startOfYear(year);\n}\n\nfunction getYearType(year: number) {\n let yearLength = getDaysInYear(year);\n\n if (yearLength > 380) {\n yearLength -= 30; // Subtract length of leap month.\n }\n\n switch (yearLength) {\n case 353:\n return 0; // deficient\n case 354:\n return 1; // normal\n case 355:\n return 2; // complete\n }\n}\n\nfunction getDaysInMonth(year: number, month: number): number {\n // Normalize month numbers from 1 - 13, even on non-leap years\n if (month >= 6 && !isLeapYear(year)) {\n month++;\n }\n\n // First of all, dispose of fixed-length 29 day months\n if (month === 4 || month === 7 || month === 9 || month === 11 || month === 13) {\n return 29;\n }\n\n let yearType = getYearType(year);\n\n // If it's Heshvan, days depend on length of year\n if (month === 2) {\n return yearType === 2 ? 30 : 29;\n }\n\n // Similarly, Kislev varies with the length of year\n if (month === 3) {\n return yearType === 0 ? 29 : 30;\n }\n\n // Adar I only exists in leap years\n if (month === 6) {\n return isLeapYear(year) ? 30 : 0;\n }\n\n return 30;\n}\n\n/**\n * The Hebrew calendar is used in Israel and around the world by the Jewish faith.\n * Years include either 12 or 13 months depending on whether it is a leap year.\n * In leap years, an extra month is inserted at month 6.\n */\nexport class HebrewCalendar implements Calendar {\n identifier = 'hebrew';\n\n fromJulianDay(jd: number): CalendarDate {\n let d = jd - HEBREW_EPOCH;\n let m = (d * DAY_PARTS) / MONTH_PARTS; // Months (approx)\n let year = Math.floor((19 * m + 234) / 235) + 1; // Years (approx)\n let ys = startOfYear(year); // 1st day of year\n let dayOfYear = Math.floor(d - ys);\n\n // Because of the postponement rules, it's possible to guess wrong. Fix it.\n while (dayOfYear < 1) {\n year--;\n ys = startOfYear(year);\n dayOfYear = Math.floor(d - ys);\n }\n\n // Now figure out which month we're in, and the date within that month\n let month = 1;\n let monthStart = 0;\n while (monthStart < dayOfYear) {\n monthStart += getDaysInMonth(year, month);\n month++;\n }\n\n month--;\n monthStart -= getDaysInMonth(year, month);\n\n let day = dayOfYear - monthStart;\n return new CalendarDate(this, year, month, day);\n }\n\n toJulianDay(date: AnyCalendarDate) {\n let jd = startOfYear(date.year);\n for (let month = 1; month < date.month; month++) {\n jd += getDaysInMonth(date.year, month);\n }\n\n return jd + date.day + HEBREW_EPOCH;\n }\n\n getDaysInMonth(date: AnyCalendarDate): number {\n return getDaysInMonth(date.year, date.month);\n }\n\n getMonthsInYear(date: AnyCalendarDate): number {\n return isLeapYear(date.year) ? 13 : 12;\n }\n\n getDaysInYear(date: AnyCalendarDate): number {\n return getDaysInYear(date.year);\n }\n\n getYearsInEra(): number {\n // 6239 gregorian\n return 9999;\n }\n\n getEras() {\n return ['AM'];\n }\n\n balanceYearMonth(date: Mutable<AnyCalendarDate>, previousDate: AnyCalendarDate) {\n // Keep date in the same month when switching between leap years and non leap years\n if (previousDate.year !== date.year) {\n if (isLeapYear(previousDate.year) && !isLeapYear(date.year) && previousDate.month > 6) {\n date.month--;\n } else if (!isLeapYear(previousDate.year) && isLeapYear(date.year) && previousDate.month > 6) {\n date.month++;\n }\n }\n }\n}\n"],"names":[],"version":3,"file":"HebrewCalendar.module.js.map"}
|