jcal-zmanim 1.5.6 → 1.5.8
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/index.cjs +23 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +24 -7
- package/dist/index.js.map +1 -1
- package/package.json +23 -23
package/dist/index.d.cts
CHANGED
|
@@ -628,6 +628,7 @@ declare class Utils {
|
|
|
628
628
|
* Jewish calendar calculation in C# Copyright © by Ulrich and Ziporah Greve (2005)
|
|
629
629
|
*/
|
|
630
630
|
declare class Zmanim {
|
|
631
|
+
private static _sunTimesCache;
|
|
631
632
|
/**
|
|
632
633
|
* Gets sunrise and sunset time for given date and Location.
|
|
633
634
|
* Accepts a javascript Date object, a string for creating a javascript date object or a jDate object.
|
|
@@ -637,7 +638,7 @@ declare class Zmanim {
|
|
|
637
638
|
* @param {Location} location Where on the globe to calculate the sun times for.
|
|
638
639
|
* @param {Boolean} considerElevation
|
|
639
640
|
*/
|
|
640
|
-
static getSunTimes(date: Date | jDate, location: Location, considerElevation?: boolean): SunTimes;
|
|
641
|
+
static getSunTimes(date: Date | jDate | string, location: Location, considerElevation?: boolean): SunTimes;
|
|
641
642
|
/**
|
|
642
643
|
* @param {jDate | Date} date
|
|
643
644
|
* @param {Location} location
|
package/dist/index.d.ts
CHANGED
|
@@ -628,6 +628,7 @@ declare class Utils {
|
|
|
628
628
|
* Jewish calendar calculation in C# Copyright © by Ulrich and Ziporah Greve (2005)
|
|
629
629
|
*/
|
|
630
630
|
declare class Zmanim {
|
|
631
|
+
private static _sunTimesCache;
|
|
631
632
|
/**
|
|
632
633
|
* Gets sunrise and sunset time for given date and Location.
|
|
633
634
|
* Accepts a javascript Date object, a string for creating a javascript date object or a jDate object.
|
|
@@ -637,7 +638,7 @@ declare class Zmanim {
|
|
|
637
638
|
* @param {Location} location Where on the globe to calculate the sun times for.
|
|
638
639
|
* @param {Boolean} considerElevation
|
|
639
640
|
*/
|
|
640
|
-
static getSunTimes(date: Date | jDate, location: Location, considerElevation?: boolean): SunTimes;
|
|
641
|
+
static getSunTimes(date: Date | jDate | string, location: Location, considerElevation?: boolean): SunTimes;
|
|
641
642
|
/**
|
|
642
643
|
* @param {jDate | Date} date
|
|
643
644
|
* @param {Location} location
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// src/JCal/Sedra.ts
|
|
2
1
|
function _array_like_to_array(arr, len) {
|
|
3
2
|
if (len == null || len > arr.length) len = arr.length;
|
|
4
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
@@ -106,6 +105,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
106
105
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
107
106
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
108
107
|
}
|
|
108
|
+
// src/JCal/Sedra.ts
|
|
109
109
|
var _Sedra = /*#__PURE__*/ function() {
|
|
110
110
|
"use strict";
|
|
111
111
|
function _Sedra(jd, israel2) {
|
|
@@ -2895,7 +2895,9 @@ var yearTypeList = [
|
|
|
2895
2895
|
0,
|
|
2896
2896
|
7
|
|
2897
2897
|
];
|
|
2898
|
+
var elapsedDaysCache = /* @__PURE__ */ new Map();
|
|
2898
2899
|
var getElapsedDays = function(year) {
|
|
2900
|
+
if (elapsedDaysCache.has(year)) return elapsedDaysCache.get(year);
|
|
2899
2901
|
var daysCounter = 0;
|
|
2900
2902
|
var months = Utils.toInt(235 * Utils.toInt((year - 1) / 19) + // Leap months this cycle
|
|
2901
2903
|
12 * ((year - 1) % 19) + // Regular months in this cycle.
|
|
@@ -2908,6 +2910,7 @@ var getElapsedDays = function(year) {
|
|
|
2908
2910
|
if (Utils.has(daysCounter % 7, 0, 3, 5)) {
|
|
2909
2911
|
daysCounter += 1;
|
|
2910
2912
|
}
|
|
2913
|
+
elapsedDaysCache.set(year, daysCounter);
|
|
2911
2914
|
return daysCounter;
|
|
2912
2915
|
};
|
|
2913
2916
|
var _jDate = /*#__PURE__*/ function() {
|
|
@@ -3566,7 +3569,7 @@ var _jDate = /*#__PURE__*/ function() {
|
|
|
3566
3569
|
_jDate.getElapsedDays = getElapsedDays;
|
|
3567
3570
|
var jDate = _jDate;
|
|
3568
3571
|
// src/JCal/Zmanim.ts
|
|
3569
|
-
var
|
|
3572
|
+
var _Zmanim = /*#__PURE__*/ function() {
|
|
3570
3573
|
"use strict";
|
|
3571
3574
|
function _Zmanim() {
|
|
3572
3575
|
_class_call_check(this, _Zmanim);
|
|
@@ -3584,13 +3587,22 @@ var Zmanim = /*#__PURE__*/ function() {
|
|
|
3584
3587
|
* @param {Boolean} considerElevation
|
|
3585
3588
|
*/ function getSunTimes(date, location) {
|
|
3586
3589
|
var considerElevation = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
3590
|
+
var absDate;
|
|
3587
3591
|
if (_instanceof(date, jDate)) {
|
|
3592
|
+
absDate = date.Abs;
|
|
3588
3593
|
date = date.getDate();
|
|
3589
|
-
} else
|
|
3590
|
-
date
|
|
3594
|
+
} else {
|
|
3595
|
+
if (typeof date === "string" || _instanceof(date, String)) {
|
|
3596
|
+
date = new Date(date);
|
|
3597
|
+
}
|
|
3598
|
+
if (!Utils.isValidDate(date)) {
|
|
3599
|
+
throw "Zmanim.getSunTimes: supplied date parameter cannot be converted to a Date";
|
|
3600
|
+
}
|
|
3601
|
+
absDate = jDate.absSd(date);
|
|
3591
3602
|
}
|
|
3592
|
-
|
|
3593
|
-
|
|
3603
|
+
var cacheKey = "".concat(absDate, "|").concat(location.Name, "|").concat(location.Latitude, "|").concat(location.Longitude, "|").concat(location.Elevation, "|").concat(considerElevation);
|
|
3604
|
+
if (_Zmanim._sunTimesCache.has(cacheKey)) {
|
|
3605
|
+
return _Zmanim._sunTimesCache.get(cacheKey);
|
|
3594
3606
|
}
|
|
3595
3607
|
var sunrise, sunset, zenithDeg = 90, zenithMin = 50, lonHour = 0, longitude = 0, latitude = 0, cosLat = 0, sinLat = 0, cosZen = 0, sinDec = 0, cosDec = 0, xmRise = 0, xmSet = 0, xlRise = 0, xlSet = 0, aRise = 0, aSet = 0, ahrRise = 0, ahrSet = 0, hRise = 0, hSet = 0, tRise = 0, tSet = 0, utRise = 0, utSet = 0;
|
|
3596
3608
|
var day = _Zmanim.dayOfYear(date), earthRadius = 6356900, zenithAtElevation = _Zmanim.degToDec(zenithDeg, zenithMin) + _Zmanim.radToDeg(Math.acos(earthRadius / (earthRadius + (considerElevation ? location.Elevation : 0))));
|
|
@@ -3646,10 +3658,13 @@ var Zmanim = /*#__PURE__*/ function() {
|
|
|
3646
3658
|
sunset.hour += 12;
|
|
3647
3659
|
}
|
|
3648
3660
|
}
|
|
3649
|
-
|
|
3661
|
+
var result = {
|
|
3650
3662
|
sunrise: sunrise,
|
|
3651
3663
|
sunset: sunset
|
|
3652
3664
|
};
|
|
3665
|
+
_Zmanim._sunTimesCache.set(cacheKey, result);
|
|
3666
|
+
if (_Zmanim._sunTimesCache.size > 2e3) _Zmanim._sunTimesCache.clear();
|
|
3667
|
+
return result;
|
|
3653
3668
|
}
|
|
3654
3669
|
},
|
|
3655
3670
|
{
|
|
@@ -3839,6 +3854,8 @@ var Zmanim = /*#__PURE__*/ function() {
|
|
|
3839
3854
|
]);
|
|
3840
3855
|
return _Zmanim;
|
|
3841
3856
|
}();
|
|
3857
|
+
_Zmanim._sunTimesCache = /* @__PURE__ */ new Map();
|
|
3858
|
+
var Zmanim = _Zmanim;
|
|
3842
3859
|
// src/Utils.ts
|
|
3843
3860
|
var __DEV__ = process.env.NODE_ENV === "development";
|
|
3844
3861
|
var DaysOfWeek = Object.freeze({
|