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,666 @@
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
+ const Zmanim_1 = __importDefault(require("./Zmanim"));
7
+ const jDate_1 = __importDefault(require("./jDate"));
8
+ class Utils {
9
+ /**
10
+ * Gets the Jewish representation of a number (365 = שס"ה)
11
+ * Minimum number is 1 and maximum is 9999.
12
+ * @param {Number} number
13
+ */
14
+ static toJNum(number) {
15
+ if (number < 1) {
16
+ throw 'Min value is 1';
17
+ }
18
+ if (number > 9999) {
19
+ throw 'Max value is 9999';
20
+ }
21
+ let n = number, retval = '';
22
+ if (n >= 1000) {
23
+ retval += Utils.jsd[Utils.toInt((n - (n % 1000)) / 1000) - 1] + "'";
24
+ n = n % 1000;
25
+ }
26
+ while (n >= 400) {
27
+ retval += 'ת';
28
+ n -= 400;
29
+ }
30
+ if (n >= 100) {
31
+ retval += Utils.jhd[Utils.toInt((n - (n % 100)) / 100) - 1];
32
+ n = n % 100;
33
+ }
34
+ if (n == 15) {
35
+ retval += 'טו';
36
+ }
37
+ else if (n == 16) {
38
+ retval += 'טז';
39
+ }
40
+ else {
41
+ if (n > 9) {
42
+ retval += Utils.jtd[Utils.toInt((n - (n % 10)) / 10) - 1];
43
+ }
44
+ if (n % 10 > 0) {
45
+ retval += Utils.jsd[(n % 10) - 1];
46
+ }
47
+ }
48
+ if (number > 999 && number % 1000 < 10) {
49
+ retval = "'" + retval;
50
+ }
51
+ else if (retval.length > 1) {
52
+ retval = retval.slice(0, -1) + '"' + retval[retval.length - 1];
53
+ }
54
+ return retval;
55
+ }
56
+ /**
57
+ * Returns the javascript date in the format: Thursday, the 3rd of January 2018.
58
+ * @param {Date} date
59
+ * @param {Boolean} hideDayOfWeek
60
+ * @param {Boolean} dontCapitalize
61
+ */
62
+ static toStringDate(date, hideDayOfWeek, dontCapitalize) {
63
+ if (!date)
64
+ return;
65
+ return ((hideDayOfWeek
66
+ ? dontCapitalize
67
+ ? 't'
68
+ : 'T'
69
+ : Utils.dowEng[date.getDay()] + ', t') +
70
+ 'he ' +
71
+ Utils.toSuffixed(date.getDate()) +
72
+ ' of ' +
73
+ Utils.sMonthsEng[date.getMonth()] +
74
+ ' ' +
75
+ date.getFullYear().toString());
76
+ }
77
+ /**
78
+ * Returns the javascript date in the format: 1/3/2020.
79
+ * @param {Date} date
80
+ * @param {Boolean} monthFirst
81
+ */
82
+ static toShortStringDate(date, monthFirst) {
83
+ if (!date)
84
+ return;
85
+ const dayNum = date.getDate(), monthNum = date.getMonth() + 1;
86
+ return ((monthFirst
87
+ ? `${monthNum}/${dayNum}`
88
+ : `${dayNum < 10 ? '0' : ''}${dayNum}/${monthNum < 10 ? '0' : ''}${monthNum}`) +
89
+ '/' +
90
+ date.getFullYear().toString());
91
+ }
92
+ /**
93
+ * Add two character suffix to number. e.g. 21st, 102nd, 93rd, 500th
94
+ * @param {Number} num
95
+ */
96
+ static toSuffixed(num) {
97
+ const t = num.toString();
98
+ let suffix = 'th';
99
+ if (t.length === 1 || t[t.length - 2] !== '1') {
100
+ switch (t[t.length - 1]) {
101
+ case '1':
102
+ suffix = 'st';
103
+ break;
104
+ case '2':
105
+ suffix = 'nd';
106
+ break;
107
+ case '3':
108
+ suffix = 'rd';
109
+ break;
110
+ }
111
+ }
112
+ return t + suffix;
113
+ }
114
+ /**
115
+ * Returns if the given full secular year has a February 29th
116
+ * @param {Number} year
117
+ */
118
+ static isSecularLeapYear(year) {
119
+ return !(year % 400) || (!!(year % 100) && !(year % 4));
120
+ }
121
+ /**
122
+ * Get day of week using Javascripts getDay function.
123
+ * Important note: months starts at 1 not 0 like javascript
124
+ * The DOW returned has Sunday = 0
125
+ * @param {Number} year
126
+ * @param {Number} month
127
+ * @param {Number} day
128
+ */
129
+ static getSdDOW(year, month, day) {
130
+ return new Date(year, month - 1, day).getDay();
131
+ }
132
+ /**
133
+ * Makes sure hour is between 0 and 23 and minute is between 0 and 59.
134
+ * Overlaps get added/subtracted.
135
+ * The argument needs to be an object in the format {hour : 12, minute : 42, second : 18}
136
+ * @param {Time} time
137
+ */
138
+ static fixTime(time) {
139
+ //make a copy - javascript sends object parameters by reference
140
+ const result = {
141
+ hour: time.hour,
142
+ minute: time.minute,
143
+ second: time.second || 0,
144
+ };
145
+ while (result.second >= 60) {
146
+ result.minute += 1;
147
+ result.second -= 60;
148
+ }
149
+ while (result.second < 0) {
150
+ result.minute -= 1;
151
+ result.second += 60;
152
+ }
153
+ while (result.minute < 0) {
154
+ result.minute += 60;
155
+ result.hour--;
156
+ }
157
+ while (result.minute >= 60) {
158
+ result.minute -= 60;
159
+ result.hour++;
160
+ }
161
+ if (result.hour < 0) {
162
+ result.hour = 24 + (result.hour % 24);
163
+ }
164
+ if (result.hour > 23) {
165
+ result.hour = result.hour % 24;
166
+ }
167
+ return result;
168
+ }
169
+ /**
170
+ * Add the given number of minutes to the given time.
171
+ * The argument needs to be an object in the format {hour : 12, minute : 42, second : 18 }
172
+ *
173
+ * @param {Time} time
174
+ * @param {Number} minutes
175
+ */
176
+ static addMinutes(time, minutes) {
177
+ if (!time)
178
+ return time;
179
+ return (time &&
180
+ Utils.fixTime({
181
+ hour: time.hour,
182
+ minute: time.minute + (minutes || 0),
183
+ second: time.second,
184
+ }));
185
+ }
186
+ /**
187
+ * Add the given number of seconds to the given time.
188
+ * The argument needs to be an object in the format {hour : 12, minute :42, second : 18}
189
+ *
190
+ * @param {Time} time
191
+ * @param {Number} seconds
192
+ */
193
+ static addSeconds(time, seconds) {
194
+ return Utils.fixTime({
195
+ hour: time.hour,
196
+ minute: time.minute,
197
+ second: (time.second || 0) + seconds,
198
+ });
199
+ }
200
+ /**
201
+ * Gets the time difference between two times of day.
202
+ * If showNegative is falsey, assumes that the earlier time is always before the later time.
203
+ * So, if laterTime is less than earlierTime, the returned diff is until the next day.
204
+ * Both arguments need to be an object in the format {hour : 12, minute : 42, second : 18 }
205
+ * @param {Time} earlierTime
206
+ * @param {Time} laterTime
207
+ * @param {Boolean} [showNegative] show negative values or assume second value is next day?
208
+ * @returns{{hour:number, minute:number, second:number, sign:1|-1}}
209
+ */
210
+ static timeDiff(earlierTime, laterTime, showNegative = false) {
211
+ const earlySec = Utils.totalSeconds(earlierTime), laterSec = Utils.totalSeconds(laterTime), time = Utils.fixTime({
212
+ hour: 0,
213
+ minute: 0,
214
+ second: earlySec <= laterSec
215
+ ? laterSec - earlySec
216
+ : showNegative
217
+ ? earlySec - laterSec
218
+ : 86400 - earlySec + laterSec,
219
+ });
220
+ return Object.assign(Object.assign({}, time), { sign: earlySec <= laterSec || !showNegative ? 1 : -1 });
221
+ }
222
+ /**
223
+ * Gets the total number of minutes in the given time.
224
+ * @param {Time} time An object in the format {hour : 12, minute :42, second : 18}
225
+ */
226
+ static totalMinutes(time) {
227
+ return time ? time.hour * 60 + time.minute : 0;
228
+ }
229
+ /**
230
+ * Gets the total number of seconds in the given time.
231
+ * @param {Time} time An object in the format {hour : 12, minute :42, second : 18}
232
+ */
233
+ static totalSeconds(time) {
234
+ return time ? Utils.totalMinutes(time) * 60 + (time.second || 0) : 0;
235
+ }
236
+ /**
237
+ * Returns the time of the given javascript date as an object in the format of {hour : 23, minute :42, second: 18 }
238
+ * @param {Date} sdate
239
+ * @returns {{hour :number, minute :number, second:number }}
240
+ */
241
+ static timeFromDate(sdate) {
242
+ return {
243
+ hour: sdate.getHours(),
244
+ minute: sdate.getMinutes(),
245
+ second: sdate.getSeconds(),
246
+ };
247
+ }
248
+ /**
249
+ * Determines if the second given time is after (or at) the first given time
250
+ * @param {{hour :number, minute :number, second:number }} beforeTime
251
+ * @param {{hour :number, minute :number, second:number }} afterTime
252
+ */
253
+ static isTimeAfter(beforeTime, afterTime) {
254
+ if (!beforeTime || !afterTime)
255
+ return false;
256
+ return Utils.totalSeconds(afterTime) >= Utils.totalSeconds(beforeTime);
257
+ }
258
+ /**
259
+ * Returns the given time interval in a formatted string.
260
+ * @param {{hour:number, minute:number,second:number,sign?: 1 | -1}} time An object in the format {hour : 23, minute :42, second: 18 }
261
+ */
262
+ static getTimeIntervalTextStringHeb(time) {
263
+ let t = '';
264
+ if (time.hour > 0) {
265
+ t += `${time.hour.toString()} ${time.hour === 1 ? 'שעה' : 'שעות'}`;
266
+ }
267
+ if (time.minute > 0) {
268
+ if (t.length) {
269
+ t += ' ';
270
+ }
271
+ t += `${time.minute.toString()} ${time.minute === 1 ? 'דקה' : 'דקות'}`;
272
+ }
273
+ if ((time.second || 0) > 0) {
274
+ if (t.length) {
275
+ t += ' ';
276
+ }
277
+ t += `${Math.trunc(time.second || 0).toString()} ${time.second === 1 ? 'שנייה' : 'שניות'}`;
278
+ }
279
+ return t;
280
+ }
281
+ /**
282
+ * Returns the given time interval in a formatted string.
283
+ * @param {{hour:number, minute:number,second:number,sign?: 1 | -1}} time An object in the format {hour : 23, minute :42, second: 18 }
284
+ */
285
+ static getTimeIntervalTextString(time) {
286
+ let t = '';
287
+ if (time.hour > 0) {
288
+ t += `${time.hour.toString()} ${time.hour === 1 ? 'hour' : 'hours'}`;
289
+ }
290
+ if (time.minute > 0) {
291
+ if (t.length) {
292
+ t += ' ';
293
+ }
294
+ t += `${time.minute.toString()} ${time.minute === 1 ? 'minute' : 'minutes'}`;
295
+ }
296
+ if ((time.second || 0) > 0) {
297
+ if (t.length) {
298
+ t += ' ';
299
+ }
300
+ t += `${Math.trunc(time.second || 0).toString()} ${time.second === 1 ? 'second' : 'seconds'}`;
301
+ }
302
+ return t;
303
+ }
304
+ /**
305
+ * Returns the nusach for Sefiras Ha'omer for the given day and minhag
306
+ * @param {number} dayOfOmer The day of the Omer for which to get the nusach for
307
+ * @param {'ashkenaz'|'sefard'|'sefardi'} nusach Should it be La'Omer ("sefard") or Ba'Omer ("ashkenaz") or "sefardi" (Eidot Hamizrach)?
308
+ */
309
+ static getOmerNusach(dayOfOmer, nusach) {
310
+ const weeks = Utils.toInt(dayOfOmer / 7), days = dayOfOmer % 7;
311
+ let txt = 'היום ';
312
+ if (dayOfOmer === 1) {
313
+ txt += 'יום אחד ';
314
+ }
315
+ else {
316
+ if (dayOfOmer === 2) {
317
+ txt += 'שני ';
318
+ }
319
+ else {
320
+ if (dayOfOmer === 10) {
321
+ txt += 'עשרה ';
322
+ }
323
+ else {
324
+ txt += Utils.jsnum[Utils.toInt(dayOfOmer % 10)] + ' ';
325
+ if (dayOfOmer > 10) {
326
+ if (dayOfOmer > 20 && dayOfOmer % 10 > 0) {
327
+ txt += 'ו';
328
+ }
329
+ txt += Utils.jtnum[Utils.toInt(dayOfOmer / 10)] + ' ';
330
+ }
331
+ }
332
+ }
333
+ txt += (dayOfOmer >= 11 ? 'יום' : 'ימים') + ' ';
334
+ if (nusach === 'sefardi') {
335
+ txt += 'לעומר' + ' ';
336
+ }
337
+ if (dayOfOmer >= 7) {
338
+ txt += 'שהם ';
339
+ if (weeks === 1) {
340
+ txt += 'שבוע אחד ';
341
+ }
342
+ else if (weeks === 2) {
343
+ txt += 'שני שבועות ';
344
+ }
345
+ else if (weeks > 0) {
346
+ txt += Utils.jsnum[Utils.toInt(weeks)] + ' שבועות ';
347
+ }
348
+ if (days === 1) {
349
+ txt += 'ויום אחד ';
350
+ }
351
+ else if (days === 2) {
352
+ txt += 'ושני ימים ';
353
+ }
354
+ else if (days > 0) {
355
+ txt += 'ו' + Utils.jsnum[days] + ' ימים ';
356
+ }
357
+ }
358
+ }
359
+ if (nusach === 'sefard') {
360
+ txt += 'לעומר';
361
+ }
362
+ else if (nusach === 'ashkenaz') {
363
+ txt += 'בעומר';
364
+ }
365
+ return txt;
366
+ }
367
+ /**
368
+ * Returns the given time in a formatted string.
369
+ * @param {Time} time An object in the format {hour : 23, minute :42, second: 18 }
370
+ * @param {1 | -1} [sign]
371
+ * @param {Boolean} [army] If falsey, the returned string will be: 11:42:18 PM otherwise it will be 23:42:18
372
+ * @param {Boolean} [roundUp] If falsey, the numbers will converted to a whole number by rounding down, otherwise, up.
373
+ */
374
+ static getTimeString(time, sign, army, roundUp) {
375
+ const round = roundUp ? Math.ceil : Math.floor;
376
+ time = {
377
+ hour: round(time.hour),
378
+ minute: round(time.minute),
379
+ second: round(time.second || 0),
380
+ };
381
+ if (army) {
382
+ return ((sign && sign < 0 ? '-' : '') +
383
+ (time.hour.toString() +
384
+ ':' +
385
+ (time.minute < 10
386
+ ? '0' + time.minute.toString()
387
+ : time.minute.toString()) +
388
+ ':' +
389
+ ((time.second || 0) < 10
390
+ ? '0' + (time.second || 0).toString()
391
+ : (time.second || 0).toString())));
392
+ }
393
+ else {
394
+ return ((sign && sign < 0 ? '-' : '') +
395
+ (time.hour <= 12
396
+ ? time.hour == 0
397
+ ? 12
398
+ : time.hour
399
+ : time.hour - 12).toString() +
400
+ ':' +
401
+ (time.minute < 10
402
+ ? '0' + time.minute.toString()
403
+ : time.minute.toString()) +
404
+ ':' +
405
+ ((time.second || 0) < 10
406
+ ? '0' + (time.second || 0).toString()
407
+ : (time.second || 0).toString()) +
408
+ (time.hour < 12 ? ' AM' : ' PM'));
409
+ }
410
+ }
411
+ /**
412
+ * Gets the UTC offset in whole hours for the users time zone.
413
+ * Note: this is not affected by DST - unlike javascripts getTimezoneOffset() function which gives you the current offset.
414
+ */
415
+ static currUtcOffset() {
416
+ const date = new Date(), jan = new Date(date.getFullYear(), 0, 1), jul = new Date(date.getFullYear(), 6, 1);
417
+ return -Utils.toInt(Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()) / 60);
418
+ }
419
+ /** Determines if the given date is within DST on the users system */
420
+ static isDateDST(date) {
421
+ return (-Utils.toInt(date.getTimezoneOffset() / 60) !==
422
+ Utils.currUtcOffset());
423
+ }
424
+ /**
425
+ * Determines if the given date is within DST in the given location
426
+ * Note: This may not be correct if the user has set the Location to a
427
+ * time zone outside Israel or the USA which is not the current system time zone.
428
+ */
429
+ static isDST(location, date) {
430
+ //If the current system time zone is the same as the given locations time zone
431
+ if (location.UTCOffset === Utils.currUtcOffset()) {
432
+ //We can use the system data to determine if the given date is within DST
433
+ return Utils.isDateDST(date);
434
+ }
435
+ else if (location.Israel) {
436
+ return Utils.isIsrael_DST(date);
437
+ }
438
+ else {
439
+ return Utils.isUSA_DST(date);
440
+ }
441
+ }
442
+ /**
443
+ * Determines if the given javascript date is during DST according to the USA rules
444
+ * @param {Date} date A javascript Date object
445
+ */
446
+ static isUSA_DST(date) {
447
+ const year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate(), hour = date.getHours();
448
+ if (month < 3 || month == 12) {
449
+ return false;
450
+ }
451
+ else if (month > 3 && month < 11) {
452
+ return true;
453
+ }
454
+ //DST starts at 2 AM on the second Sunday in March
455
+ else if (month === 3) {
456
+ //March
457
+ //Gets day of week on March 1st
458
+ const firstDOW = Utils.getSdDOW(year, 3, 1),
459
+ //Gets date of second Sunday
460
+ targetDate = firstDOW == 0 ? 8 : 7 - ((firstDOW + 7) % 7) + 8;
461
+ return day > targetDate || (day === targetDate && hour >= 2);
462
+ }
463
+ //DST ends at 2 AM on the first Sunday in November //dt.Month == 11 / November
464
+ else {
465
+ //Gets day of week on November 1st
466
+ const firstDOW = Utils.getSdDOW(year, 11, 1),
467
+ //Gets date of first Sunday
468
+ targetDate = firstDOW === 0 ? 1 : 7 - ((firstDOW + 7) % 7) + 1;
469
+ return day < targetDate || (day === targetDate && hour < 2);
470
+ }
471
+ }
472
+ //
473
+ /**
474
+ * Determines if the given Javascript date is during DST according to the current (5776) Israeli rules
475
+ * @param {Date} date A Javascript Date object
476
+ */
477
+ static isIsrael_DST(date) {
478
+ const year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate(), hour = date.getHours();
479
+ if (month > 10 || month < 3) {
480
+ return false;
481
+ }
482
+ else if (month > 3 && month < 10) {
483
+ return true;
484
+ }
485
+ //DST starts at 2 AM on the Friday before the last Sunday in March
486
+ else if (month === 3) {
487
+ //March
488
+ //Gets date of the Friday before the last Sunday
489
+ const lastFriday = 31 - Utils.getSdDOW(year, 3, 31) - 2;
490
+ return day > lastFriday || (day === lastFriday && hour >= 2);
491
+ }
492
+ //DST ends at 2 AM on the last Sunday in October //dt.Month === 10 / October
493
+ else {
494
+ //Gets date of last Sunday in October
495
+ const lastSunday = 31 - Utils.getSdDOW(year, 10, 31);
496
+ return day < lastSunday || (day === lastSunday && hour < 2);
497
+ }
498
+ }
499
+ /** The current time in Israel - determined by the current users system time and time zone offset*/
500
+ static getSdNowInIsrael() {
501
+ const now = new Date(),
502
+ //first determine the hour differential between this user and Israel time
503
+ israelTimeOffset = 2 + -Utils.currUtcOffset();
504
+ //This will give us the current correct date and time in Israel
505
+ now.setHours(now.getHours() + israelTimeOffset);
506
+ return now;
507
+ }
508
+ /**
509
+ * Adds the given number of days to the given javascript date and returns the new date
510
+ * @param {Date} sdate
511
+ * @param {Number} days
512
+ */
513
+ static addDaysToSdate(sdate, days) {
514
+ return new Date(sdate.valueOf() + 8.64e7 * days);
515
+ }
516
+ /**
517
+ * Compares two js dates to se if they both refer to the same day - time is ignored.
518
+ * @param {Date} sdate1
519
+ * @param {Date} sdate2
520
+ */
521
+ static isSameSdate(sdate1, sdate2) {
522
+ return (sdate1 && sdate2 && sdate1.toDateString() === sdate2.toDateString());
523
+ }
524
+ /**
525
+ * Compares two jDates to se if they both refer to the same day - time is ignored.
526
+ * @param {jDate} jdate1
527
+ * @param {jDate} jdate2
528
+ */
529
+ static isSameJdate(jdate1, jdate2) {
530
+ return (jdate1 &&
531
+ jdate2 &&
532
+ jdate1.Abs &&
533
+ jdate2.Abs &&
534
+ jdate1.Abs === jdate2.Abs);
535
+ }
536
+ /**
537
+ * Compares two jDates to see if they both refer to the same Jewish Month.
538
+ * @param {jDate} jdate1
539
+ * @param {jDate} jdate2
540
+ */
541
+ static isSameJMonth(jdate1, jdate2) {
542
+ return jdate1.Month === jdate2.Month && jdate1.Year === jdate2.Year;
543
+ }
544
+ /**
545
+ * Compares two dates to se if they both refer to the same Secular Month.
546
+ * @param {Date} sdate1
547
+ * @param {Date} sdate2
548
+ */
549
+ static isSameSMonth(sdate1, sdate2) {
550
+ return (sdate1.getMonth() === sdate2.getMonth() &&
551
+ sdate1.getFullYear() === sdate2.getFullYear());
552
+ }
553
+ /**
554
+ * Determines if the time of the given Date() is after sunset at the given Location
555
+ * @param {Date} sdate
556
+ * @param {Location} location
557
+ */
558
+ static isAfterSunset(sdate, location) {
559
+ const shkia = Zmanim_1.default.getSunTimes(sdate, location).sunset, now = Utils.timeFromDate(sdate);
560
+ return shkia && Utils.isTimeAfter(shkia, now);
561
+ }
562
+ /**
563
+ * Gets the current Jewish Date at the given Location
564
+ * @param {Location} location
565
+ */
566
+ static nowAtLocation(location) {
567
+ let sdate = new Date();
568
+ //if isAfterSunset a day is added.
569
+ if (Utils.isAfterSunset(sdate, location)) {
570
+ sdate.setDate(sdate.getDate() + 1);
571
+ }
572
+ return new jDate_1.default(sdate);
573
+ }
574
+ /**
575
+ * Converts the given complex number to an integer by removing the decimal part.
576
+ * Returns same results as Math.floor for positive numbers and Math.ceil for negative ones.
577
+ * Almost identical functionality to Math.trunc and parseInt.
578
+ * The difference is if the argument is NaN. Math.trunc returns NaN while ths fuction returns 0.
579
+ * In performance tests, this function was found to be quicker than the alternatives.
580
+ * @param {Number} float The complex number to convert to an integer
581
+ */
582
+ static toInt(float) {
583
+ return float | 0;
584
+ }
585
+ }
586
+ Utils.jMonthsEng = [
587
+ '',
588
+ 'Nissan',
589
+ 'Iyar',
590
+ 'Sivan',
591
+ 'Tamuz',
592
+ 'Av',
593
+ 'Ellul',
594
+ 'Tishrei',
595
+ 'Cheshvan',
596
+ 'Kislev',
597
+ 'Teves',
598
+ 'Shvat',
599
+ 'Adar',
600
+ 'Adar Sheini',
601
+ ];
602
+ Utils.jMonthsHeb = [
603
+ '',
604
+ 'ניסן',
605
+ 'אייר',
606
+ 'סיון',
607
+ 'תמוז',
608
+ 'אב',
609
+ 'אלול',
610
+ 'תשרי',
611
+ 'חשון',
612
+ 'כסלו',
613
+ 'טבת',
614
+ 'שבט',
615
+ 'אדר',
616
+ 'אדר שני',
617
+ ];
618
+ Utils.sMonthsEng = [
619
+ 'January',
620
+ 'February',
621
+ 'March',
622
+ 'April',
623
+ 'May',
624
+ 'June',
625
+ 'July',
626
+ 'August',
627
+ 'September',
628
+ 'October',
629
+ 'November',
630
+ 'December',
631
+ ];
632
+ Utils.dowEng = [
633
+ 'Sunday',
634
+ 'Monday',
635
+ 'Tuesday',
636
+ 'Wednesday',
637
+ 'Thursday',
638
+ 'Erev Shabbos',
639
+ 'Shabbos Kodesh',
640
+ ];
641
+ Utils.dowHeb = [
642
+ 'יום ראשון',
643
+ 'יום שני',
644
+ 'יום שלישי',
645
+ 'יום רביעי',
646
+ 'יום חמישי',
647
+ 'ערב שבת קודש',
648
+ 'שבת קודש',
649
+ ];
650
+ Utils.jsd = ['א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט'];
651
+ Utils.jtd = ['י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ'];
652
+ Utils.jhd = ['ק', 'ר', 'ש', 'ת'];
653
+ Utils.jsnum = [
654
+ '',
655
+ 'אחד',
656
+ 'שנים',
657
+ 'שלשה',
658
+ 'ארבעה',
659
+ 'חמשה',
660
+ 'ששה',
661
+ 'שבעה',
662
+ 'שמונה',
663
+ 'תשעה',
664
+ ];
665
+ Utils.jtnum = ['', 'עשר', 'עשרים', 'שלושים', 'ארבעים'];
666
+ exports.default = Utils;