@hebcal/core 3.41.2 → 3.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -4
- package/dist/bundle.js +927 -340
- package/dist/bundle.min.js +2 -2
- package/dist/greg0.mjs +20 -33
- package/dist/hdate-bundle.js +41 -37
- package/dist/hdate-bundle.min.js +2 -2
- package/dist/hdate.js +40 -36
- package/dist/hdate.mjs +34 -34
- package/dist/hdate0-bundle.js +21 -34
- package/dist/hdate0-bundle.min.js +2 -2
- package/dist/hdate0.mjs +19 -32
- package/dist/index.js +394 -95
- package/dist/index.mjs +394 -95
- package/hebcal.d.ts +45 -0
- package/package.json +5 -5
package/dist/hdate0.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/core v3.
|
|
1
|
+
/*! @hebcal/core v3.42.0 */
|
|
2
2
|
/*
|
|
3
3
|
* More minimal greg routines
|
|
4
4
|
*/
|
|
@@ -52,27 +52,10 @@ function isDate(obj) {
|
|
|
52
52
|
return typeof obj === 'object' && Date.prototype === obj.__proto__;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* @return {number}
|
|
60
|
-
*/
|
|
61
|
-
function dayOfYear(date) {
|
|
62
|
-
if (!isDate(date)) {
|
|
63
|
-
throw new TypeError(`Argument not a Date: ${date}`);
|
|
64
|
-
}
|
|
65
|
-
const month = date.getMonth();
|
|
66
|
-
let doy = date.getDate() + 31 * month;
|
|
67
|
-
if (month > 1) {
|
|
68
|
-
// FEB
|
|
69
|
-
doy -= Math.floor((4 * (month + 1) + 23) / 10);
|
|
70
|
-
if (isLeapYear$1(date.getFullYear())) {
|
|
71
|
-
doy++;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return doy;
|
|
75
|
-
}
|
|
55
|
+
/*
|
|
56
|
+
const ABS_14SEP1752 = 639797;
|
|
57
|
+
const ABS_2SEP1752 = 639785;
|
|
58
|
+
*/
|
|
76
59
|
|
|
77
60
|
/**
|
|
78
61
|
* Converts Gregorian date to absolute R.D. (Rata Die) days
|
|
@@ -84,14 +67,13 @@ function greg2abs(date) {
|
|
|
84
67
|
if (!isDate(date)) {
|
|
85
68
|
throw new TypeError(`Argument not a Date: ${date}`);
|
|
86
69
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
); // + Gregorian leap years
|
|
70
|
+
const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
|
|
71
|
+
/*
|
|
72
|
+
if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
|
|
73
|
+
throw new RangeError(`Invalid Date: ${date}`);
|
|
74
|
+
}
|
|
75
|
+
*/
|
|
76
|
+
return abs;
|
|
95
77
|
}
|
|
96
78
|
|
|
97
79
|
/**
|
|
@@ -115,8 +97,8 @@ function yearFromFixed(abs) {
|
|
|
115
97
|
/**
|
|
116
98
|
* @private
|
|
117
99
|
* @param {number} year
|
|
118
|
-
* @param {number} month
|
|
119
|
-
* @param {number} day
|
|
100
|
+
* @param {number} month (1-12)
|
|
101
|
+
* @param {number} day (1-31)
|
|
120
102
|
* @return {number}
|
|
121
103
|
*/
|
|
122
104
|
function toFixed(year, month, day) {
|
|
@@ -145,6 +127,11 @@ function abs2greg(abs) {
|
|
|
145
127
|
throw new TypeError(`Argument not a Number: ${abs}`);
|
|
146
128
|
}
|
|
147
129
|
abs = Math.trunc(abs);
|
|
130
|
+
/*
|
|
131
|
+
if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
|
|
132
|
+
throw new RangeError(`Invalid Date: ${abs}`);
|
|
133
|
+
}
|
|
134
|
+
*/
|
|
148
135
|
const year = yearFromFixed(abs);
|
|
149
136
|
const priorDays = abs - toFixed(year, 1, 1);
|
|
150
137
|
const correction = abs < toFixed(year, 3, 1) ? 0 : (isLeapYear$1(year) ? 1 : 2);
|