jcal-zmanim 1.0.4 → 1.0.9

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 (84) hide show
  1. package/LICENSE +674 -674
  2. package/README.md +335 -2
  3. package/{build → dist}/AppUtils.d.ts +3 -3
  4. package/dist/AppUtils.d.ts.map +1 -0
  5. package/{build → dist}/AppUtils.js +9 -5
  6. package/dist/AppUtils.js.map +1 -0
  7. package/{build → dist}/GeneralUtils.d.ts +1 -0
  8. package/dist/GeneralUtils.d.ts.map +1 -0
  9. package/{build → dist}/GeneralUtils.js +1 -0
  10. package/dist/GeneralUtils.js.map +1 -0
  11. package/{build → dist}/JCal/Dafyomi.d.ts +4 -3
  12. package/dist/JCal/Dafyomi.d.ts.map +1 -0
  13. package/{build → dist}/JCal/Dafyomi.js +4 -3
  14. package/dist/JCal/Dafyomi.js.map +1 -0
  15. package/{build → dist}/JCal/Location.d.ts +4 -4
  16. package/dist/JCal/Location.d.ts.map +1 -0
  17. package/{build → dist}/JCal/Location.js +10 -12
  18. package/dist/JCal/Location.js.map +1 -0
  19. package/{build → dist}/JCal/Molad.d.ts +1 -1
  20. package/dist/JCal/Molad.d.ts.map +1 -0
  21. package/{build → dist}/JCal/Molad.js +1 -1
  22. package/dist/JCal/Molad.js.map +1 -0
  23. package/{build → dist}/JCal/PirkeiAvos.d.ts +1 -0
  24. package/dist/JCal/PirkeiAvos.d.ts.map +1 -0
  25. package/{build → dist}/JCal/PirkeiAvos.js +1 -0
  26. package/dist/JCal/PirkeiAvos.js.map +1 -0
  27. package/{build → dist}/JCal/Sedra.d.ts +1 -0
  28. package/dist/JCal/Sedra.d.ts.map +1 -0
  29. package/{build → dist}/JCal/Sedra.js +1 -0
  30. package/dist/JCal/Sedra.js.map +1 -0
  31. package/{build → dist}/JCal/Utils.d.ts +1 -0
  32. package/dist/JCal/Utils.d.ts.map +1 -0
  33. package/{build → dist}/JCal/Utils.js +1 -0
  34. package/dist/JCal/Utils.js.map +1 -0
  35. package/{build → dist}/JCal/Zmanim.d.ts +1 -0
  36. package/dist/JCal/Zmanim.d.ts.map +1 -0
  37. package/{build → dist}/JCal/Zmanim.js +1 -0
  38. package/dist/JCal/Zmanim.js.map +1 -0
  39. package/{build → dist}/JCal/jDate.d.ts +1 -0
  40. package/dist/JCal/jDate.d.ts.map +1 -0
  41. package/{build → dist}/JCal/jDate.js +1 -0
  42. package/dist/JCal/jDate.js.map +1 -0
  43. package/dist/Locations.d.ts +31 -0
  44. package/dist/Locations.d.ts.map +1 -0
  45. package/dist/Locations.js +119 -0
  46. package/dist/Locations.js.map +1 -0
  47. package/{build → dist}/Notifications.d.ts +1 -0
  48. package/dist/Notifications.d.ts.map +1 -0
  49. package/{build → dist}/Notifications.js +1 -0
  50. package/dist/Notifications.js.map +1 -0
  51. package/{build → dist}/Settings.d.ts +9 -0
  52. package/dist/Settings.d.ts.map +1 -0
  53. package/{build → dist}/Settings.js +9 -0
  54. package/dist/Settings.js.map +1 -0
  55. package/{build → dist}/ZmanTypes.d.ts +11 -4
  56. package/dist/ZmanTypes.d.ts.map +1 -0
  57. package/{build → dist}/ZmanTypes.js +12 -5
  58. package/dist/ZmanTypes.js.map +1 -0
  59. package/dist/index.d.ts +2 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/{build → dist}/index.js +4 -1
  62. package/dist/index.js.map +1 -0
  63. package/dist/locations.json +1 -0
  64. package/package.json +40 -33
  65. package/build/Locations.d.ts +0 -7
  66. package/build/Locations.js +0 -1308
  67. package/build/index.d.ts +0 -1
  68. package/src/AppUtils.ts +0 -500
  69. package/src/GeneralUtils.ts +0 -84
  70. package/src/JCal/Dafyomi.ts +0 -139
  71. package/src/JCal/Location.ts +0 -100
  72. package/src/JCal/Molad.ts +0 -105
  73. package/src/JCal/PirkeiAvos.ts +0 -180
  74. package/src/JCal/Sedra.ts +0 -215
  75. package/src/JCal/Utils.ts +0 -732
  76. package/src/JCal/Zmanim.ts +0 -270
  77. package/src/JCal/jDate.ts +0 -714
  78. package/src/Locations.ts +0 -1303
  79. package/src/Notifications.ts +0 -1243
  80. package/src/Settings.ts +0 -103
  81. package/src/ZmanTypes.ts +0 -184
  82. package/src/index.ts +0 -31
  83. package/src/jcal-zmanim.d.ts +0 -4
  84. package/tsconfig.json +0 -109
@@ -1,270 +0,0 @@
1
-
2
- import Utils from './Utils.js';
3
- import jDate from './jDate.js';
4
- import { isValidDate } from '../GeneralUtils.js';
5
- import Location from './Location.js';
6
- import { SunTimes, Time } from '../jcal-zmanim.js';
7
-
8
- /**
9
- * Computes the daily Zmanim for any single date at any location.
10
- * The astronomical and mathematical calculations were directly adapted from the excellent
11
- * Jewish calendar calculation in C# Copyright © by Ulrich and Ziporah Greve (2005)
12
- */
13
- export default class Zmanim {
14
- /**
15
- * Gets sunrise and sunset time for given date and Location.
16
- * Accepts a javascript Date object, a string for creating a javascript date object or a jDate object.
17
- * Location object is required.
18
- * @returns {SunTimes}
19
- * @param {Date | jDate} date A Javascript Date or Jewish Date for which to calculate the sun times.
20
- * @param {Location} location Where on the globe to calculate the sun times for.
21
- * @param {Boolean} considerElevation
22
- */
23
- static getSunTimes(date: Date | jDate, location: Location, considerElevation = true): SunTimes {
24
- if (date instanceof jDate) {
25
- date = date.getDate();
26
- }
27
- else if (date instanceof String) {
28
- date = new Date(date);
29
- }
30
-
31
- if (!isValidDate(date)) {
32
- throw 'Zmanim.getSunTimes: supplied date parameter cannot be converted to a Date';
33
- }
34
-
35
- let sunrise, sunset,
36
- zenithDeg = 90, zenithMin = 50, lonHour = 0, longitude = 0, latitude = 0,
37
- cosLat = 0, sinLat = 0, cosZen = 0, sinDec = 0, cosDec = 0,
38
- xmRise = 0, xmSet = 0, xlRise = 0, xlSet = 0, aRise = 0, aSet = 0, ahrRise = 0, ahrSet = 0,
39
- hRise = 0, hSet = 0, tRise = 0, tSet = 0, utRise = 0, utSet = 0;
40
-
41
- const day = Zmanim.dayOfYear(date),
42
- earthRadius = 6356900,
43
- zenithAtElevation = Zmanim.degToDec(zenithDeg, zenithMin) +
44
- Zmanim.radToDeg(Math.acos(earthRadius / (earthRadius +
45
- (considerElevation ? location.Elevation : 0))));
46
-
47
- zenithDeg = Math.floor(zenithAtElevation);
48
- zenithMin = (zenithAtElevation - zenithDeg) * 60;
49
- cosZen = Math.cos(0.01745 * Zmanim.degToDec(zenithDeg, zenithMin));
50
- longitude = location.Longitude;
51
- lonHour = longitude / 15;
52
- latitude = location.Latitude;
53
- cosLat = Math.cos(0.01745 * latitude);
54
- sinLat = Math.sin(0.01745 * latitude);
55
- tRise = day + (6 + lonHour) / 24;
56
- tSet = day + (18 + lonHour) / 24;
57
- xmRise = Zmanim.M(tRise);
58
- xlRise = Zmanim.L(xmRise);
59
- xmSet = Zmanim.M(tSet);
60
- xlSet = Zmanim.L(xmSet);
61
- aRise = 57.29578 * Math.atan(0.91746 * Math.tan(0.01745 * xlRise));
62
- aSet = 57.29578 * Math.atan(0.91746 * Math.tan(0.01745 * xlSet));
63
- if (Math.abs(aRise + 360 - xlRise) > 90) {
64
- aRise += 180;
65
- }
66
- if (aRise > 360) {
67
- aRise -= 360;
68
- }
69
- if (Math.abs(aSet + 360 - xlSet) > 90) {
70
- aSet += 180;
71
- }
72
- if (aSet > 360) {
73
- aSet -= 360;
74
- }
75
- ahrRise = aRise / 15;
76
- sinDec = 0.39782 * Math.sin(0.01745 * xlRise);
77
- cosDec = Math.sqrt(1 - sinDec * sinDec);
78
- hRise = (cosZen - sinDec * sinLat) / (cosDec * cosLat);
79
- ahrSet = aSet / 15;
80
- sinDec = 0.39782 * Math.sin(0.01745 * xlSet);
81
- cosDec = Math.sqrt(1 - sinDec * sinDec);
82
- hSet = (cosZen - sinDec * sinLat) / (cosDec * cosLat);
83
- if (Math.abs(hRise) <= 1) {
84
- hRise = 57.29578 * Math.acos(hRise);
85
- utRise = ((360 - hRise) / 15) + ahrRise + Zmanim.adj(tRise) + lonHour;
86
- sunrise = Zmanim.timeAdj(utRise + location.UTCOffset, date, location);
87
- if (sunrise.hour > 12) {
88
- sunrise.hour -= 12;
89
- }
90
- }
91
-
92
- if (Math.abs(hSet) <= 1) {
93
- hSet = 57.29578 * Math.acos(hSet);
94
- utSet = (hRise / 15) + ahrSet + Zmanim.adj(tSet) + lonHour;
95
- sunset = Zmanim.timeAdj(utSet + location.UTCOffset, date, location);
96
- if (sunset.hour > 0 && sunset.hour < 12) {
97
- sunset.hour += 12;
98
- }
99
- }
100
-
101
- return { sunrise: sunrise, sunset: sunset };
102
- }
103
-
104
- /**
105
- * @param {jDate | Date} date
106
- * @param {Location} location
107
- */
108
- static getChatzos(date: jDate | Date, location: Location) {
109
- return Zmanim.getChatzosFromSuntimes(
110
- Zmanim.getSunTimes(date, location, false));
111
- }
112
-
113
- /**
114
- * @param {SunTimes} sunTimes
115
- */
116
- static getChatzosFromSuntimes(sunTimes: SunTimes): Time {
117
- const rise = sunTimes.sunrise,
118
- set = sunTimes.sunset;
119
-
120
- if (rise === undefined || isNaN(rise.hour) || set === undefined || isNaN(set.hour)) {
121
- return { hour: NaN, minute: NaN };
122
- }
123
- const chatz = Utils.toInt((Utils.totalSeconds(set) - Utils.totalSeconds(rise)) / 2);
124
- return Utils.addSeconds(rise, chatz);
125
- }
126
-
127
- /**
128
- * @param {jDate | Date} date
129
- * @param {Location} location
130
- * @param {any} offset
131
- */
132
- static getShaaZmanis(date: jDate | Date, location: Location, offset: number): number {
133
- return Zmanim.getShaaZmanisFromSunTimes(
134
- Zmanim.getSunTimes(date, location, false),
135
- offset);
136
- }
137
-
138
- /**
139
- * @param {{ sunrise: any; sunset: any; }} sunTimes
140
- * @param {number} [offset]
141
- */
142
- static getShaaZmanisFromSunTimes(sunTimes: SunTimes, offset?: number): number {
143
- if (!sunTimes || !sunTimes.sunrise || !sunTimes.sunset) {
144
- return 0;
145
- }
146
- let rise = sunTimes.sunrise,
147
- set = sunTimes.sunset;
148
-
149
- if (!rise || isNaN(rise.hour) || !set || isNaN(set.hour)) {
150
- return NaN;
151
- }
152
-
153
- if (offset) {
154
- rise = Utils.addMinutes(rise, -offset) as Time;
155
- set = Utils.addMinutes(set, offset) as Time;
156
- }
157
-
158
- return (Utils.totalSeconds(set) - Utils.totalSeconds(rise)) / 720;
159
- }
160
-
161
- /**
162
- * @param {{ sunrise: any; sunset: any; }} sunTimes
163
- * @param {boolean} israel
164
- */
165
- static getShaaZmanisMga(sunTimes: SunTimes, israel: boolean) {
166
- const minutes = israel ? 90 : 72;
167
- let rise = sunTimes.sunrise && Utils.addMinutes(sunTimes.sunrise, -minutes),
168
- set = sunTimes.sunset && Utils.addMinutes(sunTimes.sunset, minutes);
169
-
170
- if (!rise || isNaN(rise.hour) || !set || isNaN(set.hour)) {
171
- return NaN;
172
- }
173
-
174
- return (Utils.totalSeconds(set) - Utils.totalSeconds(rise)) / 720;
175
- }
176
-
177
- /**
178
- * @param {jDate | Date} date
179
- * @param {Location} location
180
- */
181
- static getCandleLighting(date: Date | jDate, location: Location) {
182
- return Zmanim.getCandleLightingFromSunTimes(
183
- Zmanim.getSunTimes(date, location),
184
- location);
185
- }
186
-
187
- /**
188
- * @param {SunTimes} sunTimes
189
- * @param {any} location
190
- */
191
- static getCandleLightingFromSunTimes(sunTimes: SunTimes, location: Location) {
192
- return sunTimes.sunset && Zmanim.getCandleLightingFromSunset(sunTimes.sunset, location);
193
- }
194
-
195
-
196
- /**
197
- * @param {Time} sunset
198
- * @param {Location} location
199
- */
200
- static getCandleLightingFromSunset(sunset: Time, location: Location) {
201
- return Utils.addMinutes(sunset, -(location.CandleLighting || 0));
202
- }
203
-
204
- /**
205
- * @param {Date} date
206
- */
207
- static dayOfYear(date: Date) {
208
- const month = date.getMonth(),
209
- isLeap = () => Utils.isSecularLeapYear(date.getFullYear()),
210
- yearDay = [0, 1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
211
- return yearDay[month + 1] + date.getDate() + ((month > 1 && isLeap()) ? 1 : 0);
212
- }
213
-
214
- /**
215
- * @param {number} deg
216
- * @param {number} min
217
- */
218
- static degToDec(deg: number, min: number) {
219
- return (deg + min / 60);
220
- }
221
-
222
- /**
223
- * @param {number} x
224
- */
225
- static M(x: number) {
226
- return (0.9856 * x - 3.251);
227
- }
228
-
229
- /**
230
- * @param {number} x
231
- */
232
- static L(x: number) {
233
- return (x + 1.916 * Math.sin(0.01745 * x) + 0.02 * Math.sin(2 * 0.01745 * x) + 282.565);
234
- }
235
-
236
- /**
237
- * @param {number} x
238
- */
239
- static adj(x: number) {
240
- return (-0.06571 * x - 6.62);
241
- }
242
-
243
- /**
244
- * @param {number} rad
245
- */
246
- static radToDeg(rad: number) {
247
- return 57.29578 * rad;
248
- }
249
-
250
- /**
251
- * @param {number} time
252
- * @param {Date} date
253
- * @param {Location} location
254
- */
255
- static timeAdj(time: number, date: Date, location: Location) {
256
- if (time < 0) {
257
- time += 24;
258
- }
259
- let hour = Utils.toInt(time);
260
- const minFloat = (time - hour) * 60 + 0.5,
261
- min = Utils.toInt(minFloat),
262
- sec = Math.round(60.0 * (minFloat - min));
263
-
264
- if (Utils.isDST(location, date)) {
265
- hour++;
266
- }
267
-
268
- return Utils.fixTime({ hour: hour, minute: min, second: sec });
269
- }
270
- }