jcal-zmanim 1.0.4

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 (50) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +2 -0
  3. package/build/AppUtils.d.ts +109 -0
  4. package/build/AppUtils.js +394 -0
  5. package/build/GeneralUtils.d.ts +43 -0
  6. package/build/GeneralUtils.js +93 -0
  7. package/build/JCal/Dafyomi.d.ts +27 -0
  8. package/build/JCal/Dafyomi.js +131 -0
  9. package/build/JCal/Location.d.ts +33 -0
  10. package/build/JCal/Location.js +80 -0
  11. package/build/JCal/Molad.d.ts +39 -0
  12. package/build/JCal/Molad.js +95 -0
  13. package/build/JCal/PirkeiAvos.d.ts +13 -0
  14. package/build/JCal/PirkeiAvos.js +172 -0
  15. package/build/JCal/Sedra.d.ts +63 -0
  16. package/build/JCal/Sedra.js +186 -0
  17. package/build/JCal/Utils.d.ts +225 -0
  18. package/build/JCal/Utils.js +666 -0
  19. package/build/JCal/Zmanim.d.ts +95 -0
  20. package/build/JCal/Zmanim.js +224 -0
  21. package/build/JCal/jDate.d.ts +203 -0
  22. package/build/JCal/jDate.js +647 -0
  23. package/build/Locations.d.ts +7 -0
  24. package/build/Locations.js +1308 -0
  25. package/build/Notifications.d.ts +14 -0
  26. package/build/Notifications.js +1040 -0
  27. package/build/Settings.d.ts +25 -0
  28. package/build/Settings.js +75 -0
  29. package/build/ZmanTypes.d.ts +34 -0
  30. package/build/ZmanTypes.js +184 -0
  31. package/build/index.d.ts +1 -0
  32. package/build/index.js +59 -0
  33. package/package.json +33 -0
  34. package/src/AppUtils.ts +500 -0
  35. package/src/GeneralUtils.ts +84 -0
  36. package/src/JCal/Dafyomi.ts +139 -0
  37. package/src/JCal/Location.ts +100 -0
  38. package/src/JCal/Molad.ts +105 -0
  39. package/src/JCal/PirkeiAvos.ts +180 -0
  40. package/src/JCal/Sedra.ts +215 -0
  41. package/src/JCal/Utils.ts +732 -0
  42. package/src/JCal/Zmanim.ts +270 -0
  43. package/src/JCal/jDate.ts +714 -0
  44. package/src/Locations.ts +1303 -0
  45. package/src/Notifications.ts +1243 -0
  46. package/src/Settings.ts +103 -0
  47. package/src/ZmanTypes.ts +184 -0
  48. package/src/index.ts +31 -0
  49. package/src/jcal-zmanim.d.ts +4 -0
  50. package/tsconfig.json +109 -0
@@ -0,0 +1,109 @@
1
+ import Location from './JCal/Location';
2
+ import Settings from './Settings';
3
+ import jDate from './JCal/jDate';
4
+ import { SunTimes, Time, ZmanToShow } from './jcal-zmanim';
5
+ type ZmanTime = {
6
+ date: Date;
7
+ location: Location;
8
+ sunrise: Time | undefined;
9
+ sunset: Time | undefined;
10
+ suntimesMishor: SunTimes | undefined;
11
+ sunriseMishor: Time | undefined;
12
+ sunsetMishor: Time | undefined;
13
+ mishorNeg90: Time | undefined;
14
+ chatzos: Time | undefined;
15
+ shaaZmanis: number | undefined;
16
+ shaaZmanisMga: number | undefined;
17
+ };
18
+ export declare const DaysOfWeek: Readonly<{
19
+ SUNDAY: 0;
20
+ MONDAY: 1;
21
+ TUESDAY: 2;
22
+ WEDNESDAY: 3;
23
+ THURSDAY: 4;
24
+ FRIDAY: 5;
25
+ SHABBOS: 6;
26
+ }>;
27
+ export declare const WhichDaysFlags: Readonly<{
28
+ SUNDAY: 1;
29
+ MONDAY: 2;
30
+ TUESDAY: 4;
31
+ WEDNESDAY: 8;
32
+ THURSDAY: 16;
33
+ FRIDAY: 32;
34
+ SHABBOS: 64;
35
+ YOMTOV: 128;
36
+ }>;
37
+ export default class AppUtils {
38
+ static zmanTimesCache: ZmanTime[];
39
+ /**
40
+ * Returns the date corrected time of the given zmanim on the given date at the given location
41
+ * If the zman is after or within 30 minutes of the given time, this days zman is returned, othwise tomorrows zman is returned.
42
+ * @param {Date} sdate
43
+ * @param {jDate} jdate
44
+ * @param {Time} time
45
+ * @param {Settings} settings
46
+ * @param {Time} sunset
47
+ * @returns {[{zmanType:ZmanToShow,time:Time, isTomorrow:boolean}]}
48
+ */
49
+ static getCorrectZmanTimes(sdate: Date, jdate: jDate, time: Time, settings: Settings, sunset: Time): {
50
+ zmanType: ZmanToShow;
51
+ time: Time;
52
+ isTomorrow: boolean;
53
+ }[];
54
+ /**
55
+ * Gets the zmanim for all the types in the given list.
56
+ * @param {[ZmanToShow]} zmanTypes An array of ZmanTypes to get the zman for.
57
+ * @param {Date} date The secular date to get the zmanim for
58
+ * @param {jDate} jdate The jewish date to get the zmanim for
59
+ * @param {Location} location The location for which to get the zmanim
60
+ * @returns{[{zmanType:{id:number,offset:?number,desc:string,eng:string,heb:string },time:Time}]}
61
+ */
62
+ static getZmanTimes(zmanTypes: ZmanToShow[], date: Date, jdate: jDate, location: Location): {
63
+ zmanType: ZmanToShow;
64
+ time?: Time;
65
+ }[];
66
+ /**
67
+ * Get the WhichDaysFlags for the given secular date
68
+ * @param {Date} date
69
+ * @param {jDate} jdate
70
+ * @param {Location} location
71
+ */
72
+ static getWhichDays(date: Date, jdate: jDate, location: Location): 1 | 0 | 2 | 4 | 8 | 16 | 32 | 64 | 128;
73
+ /**
74
+ * Returns the zmanim necessary for showing basic shul notifications: chatzosHayom, chatzosHalayla, alos
75
+ * @param {jDate} jdate
76
+ * @param {Date} sdate
77
+ * @param {Location} location
78
+ * @returns {{chatzosHayom:Time, chatzosHalayla:Time, alos:Time, shkia:Time }}
79
+ */
80
+ static getBasicShulZmanim(jdate: jDate, sdate: Date, location: Location): {
81
+ chatzosHayom: Time | undefined;
82
+ chatzosHalayla: Time | undefined;
83
+ alos: Time | undefined;
84
+ shkia: Time | undefined;
85
+ };
86
+ /**
87
+ * Returns all the zmanim for the given day
88
+ * @param {jDate} jdate
89
+ * @param {Date} sdate
90
+ * @param {Location} location
91
+ * @returns {{zmanType:ZmanToShow, time?:Time }[]}
92
+ */
93
+ static getAllZmanim(jdate: jDate, sdate: Date, location: Location): {
94
+ zmanType: ZmanToShow;
95
+ time?: Time | undefined;
96
+ }[];
97
+ /**
98
+ * Compares two zmanim for showing to see if they are the same
99
+ * @param {{id:number,offset:?Number, whichDaysFlags:?Number, desc: String, eng: String, heb: String }} zman1
100
+ * @param {{id:number,offset:?Number, whichDaysFlags:?Number, desc: String, eng: String, heb: String }} zman2
101
+ */
102
+ static IsSameZmanToShow(zman1: ZmanToShow, zman2: ZmanToShow): boolean;
103
+ /**
104
+ * Returns all available ZmanTypes - including baseTypes and custom added types
105
+ * @param {Settings} settings
106
+ */
107
+ static AllZmanTypes(settings: Settings): ZmanToShow[];
108
+ }
109
+ export {};
@@ -0,0 +1,394 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WhichDaysFlags = exports.DaysOfWeek = void 0;
7
+ const Utils_1 = __importDefault(require("./JCal/Utils"));
8
+ const Zmanim_1 = __importDefault(require("./JCal/Zmanim"));
9
+ const ZmanTypes_1 = require("./ZmanTypes");
10
+ exports.DaysOfWeek = Object.freeze({
11
+ SUNDAY: 0,
12
+ MONDAY: 1,
13
+ TUESDAY: 2,
14
+ WEDNESDAY: 3,
15
+ THURSDAY: 4,
16
+ FRIDAY: 5,
17
+ SHABBOS: 6,
18
+ });
19
+ exports.WhichDaysFlags = Object.freeze({
20
+ SUNDAY: 1,
21
+ MONDAY: 2,
22
+ TUESDAY: 4,
23
+ WEDNESDAY: 8,
24
+ THURSDAY: 16,
25
+ FRIDAY: 32,
26
+ SHABBOS: 64,
27
+ YOMTOV: 128,
28
+ });
29
+ class AppUtils {
30
+ /**
31
+ * Returns the date corrected time of the given zmanim on the given date at the given location
32
+ * If the zman is after or within 30 minutes of the given time, this days zman is returned, othwise tomorrows zman is returned.
33
+ * @param {Date} sdate
34
+ * @param {jDate} jdate
35
+ * @param {Time} time
36
+ * @param {Settings} settings
37
+ * @param {Time} sunset
38
+ * @returns {[{zmanType:ZmanToShow,time:Time, isTomorrow:boolean}]}
39
+ */
40
+ static getCorrectZmanTimes(sdate, jdate, time, settings, sunset) {
41
+ const correctedTimes = [], zmanTypes = settings.zmanimToShow, location = settings.location, tomorrowJd = jdate.addDays(1), tomorrowSd = Utils_1.default.addDaysToSdate(sdate, 1),
42
+ /* Candle lighting and chometz times are not shown after sunset.
43
+ This solves the issue of Candle lighting showing as having "passed 20 minutes ago"
44
+ Thursday evening after sunset - which shows as hasCandleLighting = true
45
+ as it is already Friday... */
46
+ zmanTimes = AppUtils.getZmanTimes(zmanTypes.filter((zt) => ![21, 22, 23].includes(zt.id) || Utils_1.default.isTimeAfter(time, sunset)), sdate, jdate, location), tomorrowTimes = AppUtils.getZmanTimes(
47
+ //Candle lighting tomorrow is never shown...
48
+ zmanTypes.filter((zt) => zt.id !== 21), tomorrowSd, tomorrowJd, location);
49
+ for (let zt of zmanTimes) {
50
+ let oTime = zt.time, isTomorrow = false, diff = Utils_1.default.timeDiff(time, oTime, true);
51
+ if (diff.sign < 1 &&
52
+ Utils_1.default.totalMinutes(diff) >= settings.minToShowPassedZman) {
53
+ const tom = tomorrowTimes.find((t) => t.zmanType === zt.zmanType);
54
+ if (tom && tom.time) {
55
+ oTime = tom.time;
56
+ isTomorrow = true;
57
+ }
58
+ }
59
+ correctedTimes.push({
60
+ zmanType: zt.zmanType,
61
+ time: oTime,
62
+ isTomorrow,
63
+ });
64
+ }
65
+ return correctedTimes.sort((a, b) => (a.isTomorrow ? 1 : -1) - (b.isTomorrow ? 1 : -1) ||
66
+ Utils_1.default.totalSeconds(a.time) - Utils_1.default.totalSeconds(b.time));
67
+ }
68
+ /**
69
+ * Gets the zmanim for all the types in the given list.
70
+ * @param {[ZmanToShow]} zmanTypes An array of ZmanTypes to get the zman for.
71
+ * @param {Date} date The secular date to get the zmanim for
72
+ * @param {jDate} jdate The jewish date to get the zmanim for
73
+ * @param {Location} location The location for which to get the zmanim
74
+ * @returns{[{zmanType:{id:number,offset:?number,desc:string,eng:string,heb:string },time:Time}]}
75
+ */
76
+ static getZmanTimes(zmanTypes, date, jdate, location) {
77
+ const mem = AppUtils.zmanTimesCache.find((z) => Utils_1.default.isSameSdate(z.date, date) &&
78
+ z.location.Name === location.Name), zmanTimes = [], whichDay = AppUtils.getWhichDays(date, jdate, location);
79
+ let sunrise, sunset, suntimesMishor, sunriseMishor, sunsetMishor, mishorNeg90, chatzos, shaaZmanis, shaaZmanisMga;
80
+ if (mem) {
81
+ sunrise = mem.sunrise;
82
+ sunset = mem.sunset;
83
+ suntimesMishor = mem.suntimesMishor;
84
+ sunriseMishor = mem.sunriseMishor;
85
+ sunsetMishor = mem.sunsetMishor;
86
+ mishorNeg90 = mem.mishorNeg90;
87
+ chatzos = mem.chatzos;
88
+ shaaZmanis = mem.shaaZmanis;
89
+ shaaZmanisMga = mem.shaaZmanisMga;
90
+ }
91
+ else {
92
+ const suntimes = Zmanim_1.default.getSunTimes(date, location, true);
93
+ sunrise = suntimes.sunrise;
94
+ sunset = suntimes.sunset;
95
+ suntimesMishor = Zmanim_1.default.getSunTimes(date, location, false);
96
+ sunriseMishor = suntimesMishor.sunrise;
97
+ sunsetMishor = suntimesMishor.sunset;
98
+ mishorNeg90 = Utils_1.default.addMinutes(sunriseMishor, -90);
99
+ chatzos =
100
+ sunriseMishor &&
101
+ sunsetMishor &&
102
+ Zmanim_1.default.getChatzosFromSuntimes(suntimesMishor);
103
+ shaaZmanis =
104
+ sunriseMishor &&
105
+ sunsetMishor &&
106
+ Zmanim_1.default.getShaaZmanisFromSunTimes(suntimesMishor);
107
+ shaaZmanisMga =
108
+ sunriseMishor &&
109
+ sunsetMishor &&
110
+ Zmanim_1.default.getShaaZmanisMga(suntimesMishor, true);
111
+ AppUtils.zmanTimesCache.push({
112
+ date,
113
+ location,
114
+ sunrise,
115
+ sunset,
116
+ suntimesMishor,
117
+ sunriseMishor,
118
+ sunsetMishor,
119
+ mishorNeg90,
120
+ chatzos,
121
+ shaaZmanis,
122
+ shaaZmanisMga,
123
+ });
124
+ }
125
+ for (let zmanType of zmanTypes) {
126
+ const offset = zmanType.offset &&
127
+ (!zmanType.whichDaysFlags || zmanType.whichDaysFlags & whichDay)
128
+ ? zmanType.offset
129
+ : 0;
130
+ switch (zmanType.id) {
131
+ case ZmanTypes_1.ZmanTypeIds.ChatzosLayla: // chatzosNight
132
+ zmanTimes.push({
133
+ zmanType,
134
+ time: Utils_1.default.addMinutes(chatzos, 720 + offset),
135
+ });
136
+ break;
137
+ case ZmanTypes_1.ZmanTypeIds.Alos90: // alos90
138
+ zmanTimes.push({
139
+ zmanType,
140
+ time: offset
141
+ ? Utils_1.default.addMinutes(mishorNeg90, offset)
142
+ : mishorNeg90,
143
+ });
144
+ break;
145
+ case ZmanTypes_1.ZmanTypeIds.Alos72: // alos72
146
+ zmanTimes.push({
147
+ zmanType,
148
+ time: Utils_1.default.addMinutes(sunriseMishor, -72 + offset),
149
+ });
150
+ break;
151
+ case ZmanTypes_1.ZmanTypeIds.TalisTefillin: //talisTefillin
152
+ zmanTimes.push({
153
+ zmanType,
154
+ time: Utils_1.default.addMinutes(sunriseMishor, -36 + offset),
155
+ });
156
+ break;
157
+ case ZmanTypes_1.ZmanTypeIds.NetzAtElevation: //netzElevation
158
+ zmanTimes.push({
159
+ zmanType,
160
+ time: offset
161
+ ? Utils_1.default.addMinutes(sunrise, offset)
162
+ : sunrise,
163
+ });
164
+ break;
165
+ case ZmanTypes_1.ZmanTypeIds.NetzMishor: // netzMishor:
166
+ zmanTimes.push({
167
+ zmanType,
168
+ time: offset
169
+ ? Utils_1.default.addMinutes(sunriseMishor, offset)
170
+ : sunriseMishor,
171
+ });
172
+ break;
173
+ case ZmanTypes_1.ZmanTypeIds.szksMga: //szksMga
174
+ if (shaaZmanisMga)
175
+ zmanTimes.push({
176
+ zmanType,
177
+ time: Utils_1.default.addMinutes(mishorNeg90, Math.floor(shaaZmanisMga * 3) + offset),
178
+ });
179
+ break;
180
+ case ZmanTypes_1.ZmanTypeIds.szksGra: //szksGra
181
+ if (shaaZmanis)
182
+ zmanTimes.push({
183
+ zmanType,
184
+ time: Utils_1.default.addMinutes(sunriseMishor, Math.floor(shaaZmanis * 3) + offset),
185
+ });
186
+ break;
187
+ case ZmanTypes_1.ZmanTypeIds.sztMga: // sztMga
188
+ if (shaaZmanisMga)
189
+ zmanTimes.push({
190
+ zmanType,
191
+ time: Utils_1.default.addMinutes(mishorNeg90, Math.floor(shaaZmanisMga * 4) + offset),
192
+ });
193
+ break;
194
+ case ZmanTypes_1.ZmanTypeIds.sztGra: //sztGra
195
+ if (shaaZmanis)
196
+ zmanTimes.push({
197
+ zmanType,
198
+ time: Utils_1.default.addMinutes(sunriseMishor, Math.floor(shaaZmanis * 4) + offset),
199
+ });
200
+ break;
201
+ case ZmanTypes_1.ZmanTypeIds.chatzosDay: //chatzos
202
+ zmanTimes.push({
203
+ zmanType,
204
+ time: offset
205
+ ? Utils_1.default.addMinutes(chatzos, offset)
206
+ : chatzos,
207
+ });
208
+ break;
209
+ case ZmanTypes_1.ZmanTypeIds.minGed: //minGed
210
+ if (shaaZmanis)
211
+ zmanTimes.push({
212
+ zmanType,
213
+ time: Utils_1.default.addMinutes(chatzos, shaaZmanis * 0.5 + offset),
214
+ });
215
+ break;
216
+ case ZmanTypes_1.ZmanTypeIds.minKet: //minKet
217
+ if (shaaZmanis)
218
+ zmanTimes.push({
219
+ zmanType,
220
+ time: Utils_1.default.addMinutes(sunriseMishor, shaaZmanis * 9.5 + offset),
221
+ });
222
+ break;
223
+ case ZmanTypes_1.ZmanTypeIds.plag: //plag
224
+ if (shaaZmanis)
225
+ zmanTimes.push({
226
+ zmanType,
227
+ time: Utils_1.default.addMinutes(sunriseMishor, shaaZmanis * 10.75 + offset),
228
+ });
229
+ break;
230
+ case ZmanTypes_1.ZmanTypeIds.shkiaAtSeaLevel: //shkiaMishor
231
+ zmanTimes.push({
232
+ zmanType,
233
+ time: offset
234
+ ? Utils_1.default.addMinutes(sunsetMishor, offset)
235
+ : sunsetMishor,
236
+ });
237
+ break;
238
+ case ZmanTypes_1.ZmanTypeIds.shkiaElevation: //shkiaElevation
239
+ zmanTimes.push({
240
+ zmanType,
241
+ time: offset
242
+ ? Utils_1.default.addMinutes(sunset, offset)
243
+ : sunset,
244
+ });
245
+ break;
246
+ case ZmanTypes_1.ZmanTypeIds.tzais45: // tzais45
247
+ zmanTimes.push({
248
+ zmanType,
249
+ time: Utils_1.default.addMinutes(sunset, 45 + offset),
250
+ });
251
+ break;
252
+ case ZmanTypes_1.ZmanTypeIds.tzais50: //tzais50
253
+ zmanTimes.push({
254
+ zmanType,
255
+ time: Utils_1.default.addMinutes(sunset, 50 + offset),
256
+ });
257
+ break;
258
+ case ZmanTypes_1.ZmanTypeIds.tzais72: //tzais72
259
+ zmanTimes.push({
260
+ zmanType,
261
+ time: Utils_1.default.addMinutes(sunset, 72 + offset),
262
+ });
263
+ break;
264
+ case ZmanTypes_1.ZmanTypeIds.rabbeinuTamZmanios: //tzais72Zmaniot
265
+ if (shaaZmanis)
266
+ zmanTimes.push({
267
+ zmanType,
268
+ time: Utils_1.default.addMinutes(sunset, shaaZmanis * 1.2 + offset),
269
+ });
270
+ break;
271
+ case ZmanTypes_1.ZmanTypeIds.rabbeinuTamZmaniosMga: //tzais72ZmaniotMA
272
+ if (shaaZmanisMga)
273
+ zmanTimes.push({
274
+ zmanType,
275
+ time: Utils_1.default.addMinutes(sunset, shaaZmanisMga * 1.2 + offset),
276
+ });
277
+ break;
278
+ case ZmanTypes_1.ZmanTypeIds.candleLighting: //candleLighting
279
+ if (sunset && jdate.hasCandleLighting()) {
280
+ zmanTimes.push({
281
+ zmanType,
282
+ time: Utils_1.default.addMinutes(Zmanim_1.default.getCandleLightingFromSunset(sunset, location), offset),
283
+ });
284
+ }
285
+ break;
286
+ case ZmanTypes_1.ZmanTypeIds.SofZmanEatingChometz: //Sof Zman Achilas Chometz
287
+ if (shaaZmanisMga && jdate.Month === 1 &&
288
+ jdate.Day === 14 &&
289
+ Utils_1.default.isTimeAfter(sunrise, Utils_1.default.timeFromDate(date))) {
290
+ zmanTimes.push({
291
+ zmanType,
292
+ time: Utils_1.default.addMinutes(sunrise, -90 + offset + shaaZmanisMga * 4),
293
+ });
294
+ }
295
+ break;
296
+ case ZmanTypes_1.ZmanTypeIds.SofZmanBurnChometz: //Sof Zman Biur Chometz
297
+ if (shaaZmanisMga &&
298
+ jdate.Month === 1 &&
299
+ (jdate.Day === 14 ||
300
+ (jdate.DayOfWeek === exports.DaysOfWeek.FRIDAY &&
301
+ jdate.Day === 13)) &&
302
+ Utils_1.default.isTimeAfter(sunrise, Utils_1.default.timeFromDate(date))) {
303
+ zmanTimes.push({
304
+ zmanType,
305
+ time: Utils_1.default.addMinutes(sunrise, -90 + offset + shaaZmanisMga * 5),
306
+ });
307
+ }
308
+ break;
309
+ }
310
+ }
311
+ return zmanTimes;
312
+ }
313
+ /**
314
+ * Get the WhichDaysFlags for the given secular date
315
+ * @param {Date} date
316
+ * @param {jDate} jdate
317
+ * @param {Location} location
318
+ */
319
+ static getWhichDays(date, jdate, location) {
320
+ if (jdate.isYomTov(location.Israel)) {
321
+ return exports.WhichDaysFlags.YOMTOV;
322
+ }
323
+ switch (date.getDay()) {
324
+ case exports.DaysOfWeek.SUNDAY:
325
+ return exports.WhichDaysFlags.SUNDAY;
326
+ case exports.DaysOfWeek.MONDAY:
327
+ return exports.WhichDaysFlags.MONDAY;
328
+ case exports.DaysOfWeek.TUESDAY:
329
+ return exports.WhichDaysFlags.TUESDAY;
330
+ case exports.DaysOfWeek.WEDNESDAY:
331
+ return exports.WhichDaysFlags.WEDNESDAY;
332
+ case exports.DaysOfWeek.THURSDAY:
333
+ return exports.WhichDaysFlags.THURSDAY;
334
+ case exports.DaysOfWeek.FRIDAY:
335
+ return exports.WhichDaysFlags.FRIDAY;
336
+ case exports.DaysOfWeek.SHABBOS:
337
+ return exports.WhichDaysFlags.SHABBOS;
338
+ }
339
+ return 0;
340
+ }
341
+ /**
342
+ * Returns the zmanim necessary for showing basic shul notifications: chatzosHayom, chatzosHalayla, alos
343
+ * @param {jDate} jdate
344
+ * @param {Date} sdate
345
+ * @param {Location} location
346
+ * @returns {{chatzosHayom:Time, chatzosHalayla:Time, alos:Time, shkia:Time }}
347
+ */
348
+ static getBasicShulZmanim(jdate, sdate, location) {
349
+ const zmanim = AppUtils.getZmanTimes([
350
+ (0, ZmanTypes_1.getZmanType)(ZmanTypes_1.ZmanTypeIds.chatzosDay),
351
+ (0, ZmanTypes_1.getZmanType)(ZmanTypes_1.ZmanTypeIds.Alos90),
352
+ (0, ZmanTypes_1.getZmanType)(ZmanTypes_1.ZmanTypeIds.shkiaElevation),
353
+ (0, ZmanTypes_1.getZmanType)(ZmanTypes_1.ZmanTypeIds.candleLighting),
354
+ ], sdate, jdate, location);
355
+ return {
356
+ chatzosHayom: zmanim[0].time,
357
+ chatzosHalayla: Utils_1.default.addMinutes(zmanim[0].time, 720),
358
+ alos: zmanim[1].time,
359
+ shkia: zmanim[2].time,
360
+ };
361
+ }
362
+ /**
363
+ * Returns all the zmanim for the given day
364
+ * @param {jDate} jdate
365
+ * @param {Date} sdate
366
+ * @param {Location} location
367
+ * @returns {{zmanType:ZmanToShow, time?:Time }[]}
368
+ */
369
+ static getAllZmanim(jdate, sdate, location) {
370
+ return AppUtils.getZmanTimes(ZmanTypes_1.ZmanTypes, sdate, jdate, location);
371
+ }
372
+ /**
373
+ * Compares two zmanim for showing to see if they are the same
374
+ * @param {{id:number,offset:?Number, whichDaysFlags:?Number, desc: String, eng: String, heb: String }} zman1
375
+ * @param {{id:number,offset:?Number, whichDaysFlags:?Number, desc: String, eng: String, heb: String }} zman2
376
+ */
377
+ static IsSameZmanToShow(zman1, zman2) {
378
+ return (zman1.id === zman2.id &&
379
+ zman1.desc === zman2.desc &&
380
+ zman1.eng === zman2.eng &&
381
+ zman1.heb === zman2.heb &&
382
+ (zman1.offset || 0) === (zman2.offset || 0) &&
383
+ (zman1.whichDaysFlags || 0) === (zman2.whichDaysFlags || 0));
384
+ }
385
+ /**
386
+ * Returns all available ZmanTypes - including baseTypes and custom added types
387
+ * @param {Settings} settings
388
+ */
389
+ static AllZmanTypes(settings) {
390
+ return [...ZmanTypes_1.ZmanTypes] /*.concat(settings.customZmanim)*/;
391
+ }
392
+ }
393
+ AppUtils.zmanTimesCache = [];
394
+ exports.default = AppUtils;
@@ -0,0 +1,43 @@
1
+ /** Returns true if "thing" is either a string primitive or String object.*/
2
+ export declare function isString(thing: unknown): boolean;
3
+ /** Returns true if "thing" is either a number primitive or a Number object.*/
4
+ export declare function isNumber(thing: unknown): boolean;
5
+ /** Returns true if "thing" is a Date object containing a valid date.*/
6
+ export declare function isValidDate(thing: unknown): boolean;
7
+ /** Returns whether or not the given, array, string, or argument list contains the given item or substring.
8
+ *
9
+ * This function is awfully similar to Array.includes, but has the added plus of accepting any number or type of arguments.*/
10
+ export declare function has(o: unknown, ...arr: unknown[]): boolean;
11
+ /** Returns the first value unless it is undefined, null or NaN.
12
+ *
13
+ * This is very useful for boolean, string and integer parameters
14
+ * where we want to keep false, "" and 0 if they were supplied.
15
+ *
16
+ * Similar purpose to default parameters with the difference being that this function will return
17
+ * the second value if the first is NaN or null, while default params will give give you the NaN or the null.
18
+ */
19
+ export declare function setDefault(paramValue: unknown, defValue: unknown): unknown;
20
+ /**
21
+ * Returns an array containing a range of integers.
22
+ * @param {Number} [start] The number to start at. The start number is included in the results.
23
+ * If only one argument is supplied, start will be set to 1.
24
+ * @param {Number} end The top end of the range.
25
+ * Unlike Pythons range function, The end number is included in the results.
26
+ * @returns {[Number]}
27
+ */
28
+ export declare function range(start: number, end?: number): number[];
29
+ /**
30
+ * Log message to console
31
+ * @param {string} txt
32
+ */
33
+ export declare function log(txt: string, ...optionalItems: any[]): void;
34
+ /**
35
+ * Warn message to console
36
+ * @param {string} txt
37
+ */
38
+ export declare function warn(txt: string, ...optionalItems: any[]): void;
39
+ /**
40
+ * Error message to console
41
+ * @param {*} txt
42
+ */
43
+ export declare function error(txt: string, ...optionalItems: any[]): void;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.error = exports.warn = exports.log = exports.range = exports.setDefault = exports.has = exports.isValidDate = exports.isNumber = exports.isString = void 0;
4
+ const __DEV__ = process.env.NODE_ENV === 'development';
5
+ /** Returns true if "thing" is either a string primitive or String object.*/
6
+ function isString(thing) {
7
+ return typeof thing === 'string' || thing instanceof String;
8
+ }
9
+ exports.isString = isString;
10
+ /** Returns true if "thing" is either a number primitive or a Number object.*/
11
+ function isNumber(thing) {
12
+ return typeof thing === 'number' || thing instanceof Number;
13
+ }
14
+ exports.isNumber = isNumber;
15
+ /** Returns true if "thing" is a Date object containing a valid date.*/
16
+ function isValidDate(thing) {
17
+ return thing instanceof Date && !isNaN(thing.valueOf());
18
+ }
19
+ exports.isValidDate = isValidDate;
20
+ /** Returns whether or not the given, array, string, or argument list contains the given item or substring.
21
+ *
22
+ * This function is awfully similar to Array.includes, but has the added plus of accepting any number or type of arguments.*/
23
+ function has(o, ...arr) {
24
+ if (arr.length === 1 && (Array.isArray(arr[0]) || isString(arr[0]))) {
25
+ return arr[0].includes(o);
26
+ }
27
+ else {
28
+ return arr.includes(o);
29
+ }
30
+ }
31
+ exports.has = has;
32
+ /** Returns the first value unless it is undefined, null or NaN.
33
+ *
34
+ * This is very useful for boolean, string and integer parameters
35
+ * where we want to keep false, "" and 0 if they were supplied.
36
+ *
37
+ * Similar purpose to default parameters with the difference being that this function will return
38
+ * the second value if the first is NaN or null, while default params will give give you the NaN or the null.
39
+ */
40
+ function setDefault(paramValue, defValue) {
41
+ if (typeof paramValue === 'undefined' ||
42
+ paramValue === null ||
43
+ isNaN(paramValue)) {
44
+ return defValue;
45
+ }
46
+ else {
47
+ return paramValue;
48
+ }
49
+ }
50
+ exports.setDefault = setDefault;
51
+ /**
52
+ * Returns an array containing a range of integers.
53
+ * @param {Number} [start] The number to start at. The start number is included in the results.
54
+ * If only one argument is supplied, start will be set to 1.
55
+ * @param {Number} end The top end of the range.
56
+ * Unlike Pythons range function, The end number is included in the results.
57
+ * @returns {[Number]}
58
+ */
59
+ function range(start, end) {
60
+ const startNumber = typeof (end) === 'undefined' ? 1 : start, endNumber = typeof (end) === 'undefined' ? start : end;
61
+ return Array.from({ length: endNumber - startNumber + 1 }, (v, i) => startNumber + i);
62
+ }
63
+ exports.range = range;
64
+ /**
65
+ * Log message to console
66
+ * @param {string} txt
67
+ */
68
+ function log(txt, ...optionalItems) {
69
+ if (__DEV__) {
70
+ console.log(txt, ...optionalItems);
71
+ }
72
+ }
73
+ exports.log = log;
74
+ /**
75
+ * Warn message to console
76
+ * @param {string} txt
77
+ */
78
+ function warn(txt, ...optionalItems) {
79
+ if (__DEV__) {
80
+ console.warn(txt, ...optionalItems);
81
+ }
82
+ }
83
+ exports.warn = warn;
84
+ /**
85
+ * Error message to console
86
+ * @param {*} txt
87
+ */
88
+ function error(txt, ...optionalItems) {
89
+ if (__DEV__) {
90
+ console.error(txt, ...optionalItems);
91
+ }
92
+ }
93
+ exports.error = error;
@@ -0,0 +1,27 @@
1
+ import jDate from './jDate.js';
2
+ /** *********************************************************************************************************
3
+ * Computes the Day Yomi for the given day.
4
+ * Sample of use - to get todays daf:
5
+ * const dafEng = Dafyomi.toString(new jDate(new Date()));
6
+ * const dafHeb = Dafyomi.toStringHeb(new jDate(new Date()));
7
+ * The code was converted to javascript and tweaked by CBS.
8
+ * It is directly based on the C code in Danny Sadinoff's HebCal - Copyright (C) 1994.
9
+ * The HebCal code for dafyomi was adapted by Aaron Peromsik from Bob Newell's public domain daf.el.
10
+ ***********************************************************************************************************/
11
+ export default class Dafyomi {
12
+ static masechtaList: {
13
+ eng: string;
14
+ heb: string;
15
+ daf: number;
16
+ }[];
17
+ static getDaf(jdate: jDate): {
18
+ masechet: {
19
+ eng: string;
20
+ heb: string;
21
+ daf: number;
22
+ };
23
+ daf: number;
24
+ } | null;
25
+ static toString(jd: jDate): string | undefined;
26
+ static toStringHeb(jd: jDate): string | undefined;
27
+ }