jcal-zmanim 1.1.7 → 1.1.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.
Files changed (41) hide show
  1. package/dist/JCal/Dafyomi.js +57 -54
  2. package/dist/JCal/Dafyomi.js.map +1 -1
  3. package/dist/JCal/Location.js +17 -15
  4. package/dist/JCal/Location.js.map +1 -1
  5. package/dist/JCal/Molad.js +17 -13
  6. package/dist/JCal/Molad.js.map +1 -1
  7. package/dist/JCal/PirkeiAvos.js +140 -137
  8. package/dist/JCal/PirkeiAvos.js.map +1 -1
  9. package/dist/JCal/Sedra.js +37 -36
  10. package/dist/JCal/Sedra.js.map +1 -1
  11. package/dist/JCal/Zmanim.js +49 -44
  12. package/dist/JCal/Zmanim.js.map +1 -1
  13. package/dist/JCal/ZmanimUtils.d.ts +3 -3
  14. package/dist/JCal/ZmanimUtils.d.ts.map +1 -1
  15. package/dist/JCal/ZmanimUtils.js +220 -193
  16. package/dist/JCal/ZmanimUtils.js.map +1 -1
  17. package/dist/JCal/jDate.d.ts +1 -1
  18. package/dist/JCal/jDate.d.ts.map +1 -1
  19. package/dist/JCal/jDate.js +126 -119
  20. package/dist/JCal/jDate.js.map +1 -1
  21. package/dist/Locations.d.ts +1 -1
  22. package/dist/Locations.d.ts.map +1 -1
  23. package/dist/Locations.js +60 -19
  24. package/dist/Locations.js.map +1 -1
  25. package/dist/Notifications.d.ts +3 -3
  26. package/dist/Notifications.d.ts.map +1 -1
  27. package/dist/Notifications.js +73 -48
  28. package/dist/Notifications.js.map +1 -1
  29. package/dist/Utils.d.ts +3 -3
  30. package/dist/Utils.d.ts.map +1 -1
  31. package/dist/Utils.js +207 -150
  32. package/dist/Utils.js.map +1 -1
  33. package/dist/ZmanTypes.d.ts +1 -1
  34. package/dist/ZmanTypes.d.ts.map +1 -1
  35. package/dist/ZmanTypes.js +3 -3
  36. package/dist/ZmanTypes.js.map +1 -1
  37. package/dist/index.d.ts +71 -1
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/package.json +2 -1
package/dist/Utils.js CHANGED
@@ -1,7 +1,43 @@
1
- import Zmanim from './JCal/Zmanim';
2
- import jDate from './JCal/jDate';
3
- const __DEV__ = process.env.NODE_ENV === 'development';
4
- export const DaysOfWeek = Object.freeze({
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
29
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
30
+ if (ar || !(i in from)) {
31
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
32
+ ar[i] = from[i];
33
+ }
34
+ }
35
+ return to.concat(ar || Array.prototype.slice.call(from));
36
+ };
37
+ import Zmanim from './JCal/Zmanim.js';
38
+ import jDate from './JCal/jDate.js';
39
+ var __DEV__ = process.env.NODE_ENV === 'development';
40
+ export var DaysOfWeek = Object.freeze({
5
41
  SUNDAY: 0,
6
42
  MONDAY: 1,
7
43
  TUESDAY: 2,
@@ -10,7 +46,7 @@ export const DaysOfWeek = Object.freeze({
10
46
  FRIDAY: 5,
11
47
  SHABBOS: 6,
12
48
  });
13
- export const JewishMonthsEng = [
49
+ export var JewishMonthsEng = [
14
50
  '',
15
51
  'Nissan',
16
52
  'Iyar',
@@ -26,7 +62,7 @@ export const JewishMonthsEng = [
26
62
  'Adar',
27
63
  'Adar Sheini',
28
64
  ];
29
- export const JewishMonthsHeb = [
65
+ export var JewishMonthsHeb = [
30
66
  '',
31
67
  'ניסן',
32
68
  'אייר',
@@ -42,7 +78,7 @@ export const JewishMonthsHeb = [
42
78
  'אדר',
43
79
  'אדר שני',
44
80
  ];
45
- export const SecularMonthsEng = [
81
+ export var SecularMonthsEng = [
46
82
  'January',
47
83
  'February',
48
84
  'March',
@@ -56,7 +92,7 @@ export const SecularMonthsEng = [
56
92
  'November',
57
93
  'December',
58
94
  ];
59
- export const DaysOfWeekEng = [
95
+ export var DaysOfWeekEng = [
60
96
  'Sunday',
61
97
  'Monday',
62
98
  'Tuesday',
@@ -65,7 +101,7 @@ export const DaysOfWeekEng = [
65
101
  'Erev Shabbos',
66
102
  'Shabbos Kodesh',
67
103
  ];
68
- export const DaysOfWeekHeb = [
104
+ export var DaysOfWeekHeb = [
69
105
  'יום ראשון',
70
106
  'יום שני',
71
107
  'יום שלישי',
@@ -74,20 +110,22 @@ export const DaysOfWeekHeb = [
74
110
  'ערב שבת קודש',
75
111
  'שבת קודש',
76
112
  ];
77
- export class Utils {
113
+ var Utils = /** @class */ (function () {
114
+ function Utils() {
115
+ }
78
116
  /**
79
117
  * Gets the Jewish representation of a number (365 = שס"ה)
80
118
  * Minimum number is 1 and maximum is 9999.
81
119
  * @param {Number} number
82
120
  */
83
- static toJewishNumber(number) {
121
+ Utils.toJewishNumber = function (number) {
84
122
  if (number < 1) {
85
123
  throw 'Min value is 1';
86
124
  }
87
125
  if (number > 9999) {
88
126
  throw 'Max value is 9999';
89
127
  }
90
- let n = number, retval = '';
128
+ var n = number, retval = '';
91
129
  if (n >= 1000) {
92
130
  retval += Utils.jsd[Utils.toInt((n - (n % 1000)) / 1000) - 1] + "'";
93
131
  n = n % 1000;
@@ -121,14 +159,14 @@ export class Utils {
121
159
  retval = retval.slice(0, -1) + '"' + retval[retval.length - 1];
122
160
  }
123
161
  return retval;
124
- }
162
+ };
125
163
  /**
126
164
  * Returns the javascript date in the format: Thursday, the 3rd of January 2018.
127
165
  * @param {Date} date
128
166
  * @param {Boolean} hideDayOfWeek
129
167
  * @param {Boolean} dontCapitalize
130
168
  */
131
- static toStringDate(date, hideDayOfWeek, dontCapitalize) {
169
+ Utils.toStringDate = function (date, hideDayOfWeek, dontCapitalize) {
132
170
  if (!date)
133
171
  return;
134
172
  return ((hideDayOfWeek
@@ -142,29 +180,29 @@ export class Utils {
142
180
  SecularMonthsEng[date.getMonth()] +
143
181
  ' ' +
144
182
  date.getFullYear().toString());
145
- }
183
+ };
146
184
  /**
147
185
  * Returns the javascript date in the format: 1/3/2020.
148
186
  * @param {Date} date
149
187
  * @param {Boolean} monthFirst
150
188
  */
151
- static toShortStringDate(date, monthFirst) {
189
+ Utils.toShortStringDate = function (date, monthFirst) {
152
190
  if (!date)
153
191
  return;
154
- const dayNum = date.getDate(), monthNum = date.getMonth() + 1;
192
+ var dayNum = date.getDate(), monthNum = date.getMonth() + 1;
155
193
  return ((monthFirst
156
- ? `${monthNum}/${dayNum}`
157
- : `${dayNum < 10 ? '0' : ''}${dayNum}/${monthNum < 10 ? '0' : ''}${monthNum}`) +
194
+ ? "".concat(monthNum, "/").concat(dayNum)
195
+ : "".concat(dayNum < 10 ? '0' : '').concat(dayNum, "/").concat(monthNum < 10 ? '0' : '').concat(monthNum)) +
158
196
  '/' +
159
197
  date.getFullYear().toString());
160
- }
198
+ };
161
199
  /**
162
200
  * Add two character suffix to number. e.g. 21st, 102nd, 93rd, 500th
163
201
  * @param {Number} num
164
202
  */
165
- static toSuffixed(num) {
166
- const t = num.toString();
167
- let suffix = 'th';
203
+ Utils.toSuffixed = function (num) {
204
+ var t = num.toString();
205
+ var suffix = 'th';
168
206
  if (t.length === 1 || t[t.length - 2] !== '1') {
169
207
  switch (t[t.length - 1]) {
170
208
  case '1':
@@ -179,14 +217,14 @@ export class Utils {
179
217
  }
180
218
  }
181
219
  return t + suffix;
182
- }
220
+ };
183
221
  /**
184
222
  * Returns if the given full secular year has a February 29th
185
223
  * @param {Number} year
186
224
  */
187
- static isSecularLeapYear(year) {
225
+ Utils.isSecularLeapYear = function (year) {
188
226
  return !(year % 400) || (!!(year % 100) && !(year % 4));
189
- }
227
+ };
190
228
  /**
191
229
  * Get day of week using Javascripts getDay function.
192
230
  * Important note: months starts at 1 not 0 like javascript
@@ -195,18 +233,18 @@ export class Utils {
195
233
  * @param {Number} month
196
234
  * @param {Number} day
197
235
  */
198
- static getSdDOW(year, month, day) {
236
+ Utils.getSdDOW = function (year, month, day) {
199
237
  return new Date(year, month - 1, day).getDay();
200
- }
238
+ };
201
239
  /**
202
240
  * Makes sure hour is between 0 and 23 and minute is between 0 and 59.
203
241
  * Overlaps get added/subtracted.
204
242
  * The argument needs to be an object in the format {hour : 12, minute : 42, second : 18}
205
243
  * @param {Time} time
206
244
  */
207
- static fixTime(time) {
245
+ Utils.fixTime = function (time) {
208
246
  //make a copy - javascript sends object parameters by reference
209
- const result = {
247
+ var result = {
210
248
  hour: time.hour,
211
249
  minute: time.minute,
212
250
  second: time.second || 0,
@@ -234,7 +272,7 @@ export class Utils {
234
272
  result.hour = result.hour % 24;
235
273
  }
236
274
  return result;
237
- }
275
+ };
238
276
  /**
239
277
  * Add the given number of minutes to the given time.
240
278
  * The argument needs to be an object in the format {hour : 12, minute : 42, second : 18 }
@@ -242,7 +280,7 @@ export class Utils {
242
280
  * @param {Time} time
243
281
  * @param {Number} minutes
244
282
  */
245
- static addMinutes(time, minutes) {
283
+ Utils.addMinutes = function (time, minutes) {
246
284
  if (!time)
247
285
  return time;
248
286
  return (time &&
@@ -251,7 +289,7 @@ export class Utils {
251
289
  minute: time.minute + (minutes || 0),
252
290
  second: time.second,
253
291
  }));
254
- }
292
+ };
255
293
  /**
256
294
  * Add the given number of seconds to the given time.
257
295
  * The argument needs to be an object in the format {hour : 12, minute :42, second : 18}
@@ -259,13 +297,13 @@ export class Utils {
259
297
  * @param {Time} time
260
298
  * @param {Number} seconds
261
299
  */
262
- static addSeconds(time, seconds) {
300
+ Utils.addSeconds = function (time, seconds) {
263
301
  return Utils.fixTime({
264
302
  hour: time.hour,
265
303
  minute: time.minute,
266
304
  second: (time.second || 0) + seconds,
267
305
  });
268
- }
306
+ };
269
307
  /**
270
308
  * Gets the time difference between two times of day.
271
309
  * If showNegative is falsey, assumes that the earlier time is always before the later time.
@@ -276,8 +314,9 @@ export class Utils {
276
314
  * @param {Boolean} [showNegative] show negative values or assume second value is next day?
277
315
  * @returns{{hour:number, minute:number, second:number, sign:1|-1}}
278
316
  */
279
- static timeDiff(earlierTime, laterTime, showNegative = false) {
280
- const earlySec = Utils.totalSeconds(earlierTime), laterSec = Utils.totalSeconds(laterTime), time = Utils.fixTime({
317
+ Utils.timeDiff = function (earlierTime, laterTime, showNegative) {
318
+ if (showNegative === void 0) { showNegative = false; }
319
+ var earlySec = Utils.totalSeconds(earlierTime), laterSec = Utils.totalSeconds(laterTime), time = Utils.fixTime({
281
320
  hour: 0,
282
321
  minute: 0,
283
322
  second: earlySec <= laterSec
@@ -286,98 +325,98 @@ export class Utils {
286
325
  ? earlySec - laterSec
287
326
  : 86400 - earlySec + laterSec,
288
327
  });
289
- return Object.assign(Object.assign({}, time), { sign: earlySec <= laterSec || !showNegative ? 1 : -1 });
290
- }
328
+ return __assign(__assign({}, time), { sign: earlySec <= laterSec || !showNegative ? 1 : -1 });
329
+ };
291
330
  /**
292
331
  * Gets the total number of minutes in the given time.
293
332
  * @param {Time} time An object in the format {hour : 12, minute :42, second : 18}
294
333
  */
295
- static totalMinutes(time) {
334
+ Utils.totalMinutes = function (time) {
296
335
  return time ? time.hour * 60 + time.minute : 0;
297
- }
336
+ };
298
337
  /**
299
338
  * Gets the total number of seconds in the given time.
300
339
  * @param {Time} time An object in the format {hour : 12, minute :42, second : 18}
301
340
  */
302
- static totalSeconds(time) {
341
+ Utils.totalSeconds = function (time) {
303
342
  return time ? Utils.totalMinutes(time) * 60 + (time.second || 0) : 0;
304
- }
343
+ };
305
344
  /**
306
345
  * Returns the time of the given javascript date as an object in the format of {hour : 23, minute :42, second: 18 }
307
346
  * @param {Date} sdate
308
347
  * @returns {{hour :number, minute :number, second:number }}
309
348
  */
310
- static timeFromDate(sdate) {
349
+ Utils.timeFromDate = function (sdate) {
311
350
  return {
312
351
  hour: sdate.getHours(),
313
352
  minute: sdate.getMinutes(),
314
353
  second: sdate.getSeconds(),
315
354
  };
316
- }
355
+ };
317
356
  /**
318
357
  * Determines if the second given time is after (or at) the first given time
319
358
  * @param {{hour :number, minute :number, second:number }} beforeTime
320
359
  * @param {{hour :number, minute :number, second:number }} afterTime
321
360
  */
322
- static isTimeAfter(beforeTime, afterTime) {
361
+ Utils.isTimeAfter = function (beforeTime, afterTime) {
323
362
  if (!beforeTime || !afterTime)
324
363
  return false;
325
364
  return Utils.totalSeconds(afterTime) >= Utils.totalSeconds(beforeTime);
326
- }
365
+ };
327
366
  /**
328
367
  * Returns the given time interval in a formatted string.
329
368
  * @param {{hour:number, minute:number,second:number,sign?: 1 | -1}} time An object in the format {hour : 23, minute :42, second: 18 }
330
369
  */
331
- static getTimeIntervalTextStringHeb(time) {
332
- let t = '';
370
+ Utils.getTimeIntervalTextStringHeb = function (time) {
371
+ var t = '';
333
372
  if (time.hour > 0) {
334
- t += `${time.hour.toString()} ${time.hour === 1 ? 'שעה' : 'שעות'}`;
373
+ t += "".concat(time.hour.toString(), " ").concat(time.hour === 1 ? 'שעה' : 'שעות');
335
374
  }
336
375
  if (time.minute > 0) {
337
376
  if (t.length) {
338
377
  t += ' ';
339
378
  }
340
- t += `${time.minute.toString()} ${time.minute === 1 ? 'דקה' : 'דקות'}`;
379
+ t += "".concat(time.minute.toString(), " ").concat(time.minute === 1 ? 'דקה' : 'דקות');
341
380
  }
342
381
  if ((time.second || 0) > 0) {
343
382
  if (t.length) {
344
383
  t += ' ';
345
384
  }
346
- t += `${Math.trunc(time.second || 0).toString()} ${time.second === 1 ? 'שנייה' : 'שניות'}`;
385
+ t += "".concat(Math.trunc(time.second || 0).toString(), " ").concat(time.second === 1 ? 'שנייה' : 'שניות');
347
386
  }
348
387
  return t;
349
- }
388
+ };
350
389
  /**
351
390
  * Returns the given time interval in a formatted string.
352
391
  * @param {{hour:number, minute:number,second:number,sign?: 1 | -1}} time An object in the format {hour : 23, minute :42, second: 18 }
353
392
  */
354
- static getTimeIntervalTextString(time) {
355
- let t = '';
393
+ Utils.getTimeIntervalTextString = function (time) {
394
+ var t = '';
356
395
  if (time.hour > 0) {
357
- t += `${time.hour.toString()} ${time.hour === 1 ? 'hour' : 'hours'}`;
396
+ t += "".concat(time.hour.toString(), " ").concat(time.hour === 1 ? 'hour' : 'hours');
358
397
  }
359
398
  if (time.minute > 0) {
360
399
  if (t.length) {
361
400
  t += ' ';
362
401
  }
363
- t += `${time.minute.toString()} ${time.minute === 1 ? 'minute' : 'minutes'}`;
402
+ t += "".concat(time.minute.toString(), " ").concat(time.minute === 1 ? 'minute' : 'minutes');
364
403
  }
365
404
  if ((time.second || 0) > 0) {
366
405
  if (t.length) {
367
406
  t += ' ';
368
407
  }
369
- t += `${Math.trunc(time.second || 0).toString()} ${time.second === 1 ? 'second' : 'seconds'}`;
408
+ t += "".concat(Math.trunc(time.second || 0).toString(), " ").concat(time.second === 1 ? 'second' : 'seconds');
370
409
  }
371
410
  return t;
372
- }
411
+ };
373
412
  /**
374
413
  * Returns the nusach for Sefiras Ha'omer for the given day and minhag
375
414
  * @param {number} dayOfOmer The day of the Omer for which to get the nusach for
376
415
  * @param {'ashkenaz'|'sefard'|'sefardi'} nusach Should it be La'Omer ("sefard") or Ba'Omer ("ashkenaz") or "sefardi" (Eidot Hamizrach)?
377
416
  */
378
- static getOmerNusach(dayOfOmer, nusach) {
379
- const weeks = Utils.toInt(dayOfOmer / 7), days = dayOfOmer % 7;
380
- let txt = 'היום ';
417
+ Utils.getOmerNusach = function (dayOfOmer, nusach) {
418
+ var weeks = Utils.toInt(dayOfOmer / 7), days = dayOfOmer % 7;
419
+ var txt = 'היום ';
381
420
  if (dayOfOmer === 1) {
382
421
  txt += 'יום אחד ';
383
422
  }
@@ -432,7 +471,7 @@ export class Utils {
432
471
  txt += 'בעומר';
433
472
  }
434
473
  return txt;
435
- }
474
+ };
436
475
  /**
437
476
  * Returns the given time in a formatted string.
438
477
  * @param {Time} time An object in the format {hour : 23, minute :42, second: 18 }
@@ -440,8 +479,8 @@ export class Utils {
440
479
  * @param {Boolean} [army] If falsey, the returned string will be: 11:42:18 PM otherwise it will be 23:42:18
441
480
  * @param {Boolean} [roundUp] If falsey, the numbers will converted to a whole number by rounding down, otherwise, up.
442
481
  */
443
- static getTimeString(time, sign, army, roundUp) {
444
- const round = roundUp ? Math.ceil : Math.floor;
482
+ Utils.getTimeString = function (time, sign, army, roundUp) {
483
+ var round = roundUp ? Math.ceil : Math.floor;
445
484
  time = {
446
485
  hour: round(time.hour),
447
486
  minute: round(time.minute),
@@ -476,26 +515,26 @@ export class Utils {
476
515
  : (time.second || 0).toString()) +
477
516
  (time.hour < 12 ? ' AM' : ' PM'));
478
517
  }
479
- }
518
+ };
480
519
  /**
481
520
  * Gets the UTC offset in whole hours for the users time zone.
482
521
  * Note: this is not affected by DST - unlike javascripts getTimezoneOffset() function which gives you the current offset.
483
522
  */
484
- static currUtcOffset() {
485
- const date = new Date(), jan = new Date(date.getFullYear(), 0, 1), jul = new Date(date.getFullYear(), 6, 1);
523
+ Utils.currUtcOffset = function () {
524
+ var date = new Date(), jan = new Date(date.getFullYear(), 0, 1), jul = new Date(date.getFullYear(), 6, 1);
486
525
  return -Utils.toInt(Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()) / 60);
487
- }
526
+ };
488
527
  /** Determines if the given date is within DST on the users system */
489
- static isDateDST(date) {
528
+ Utils.isDateDST = function (date) {
490
529
  return (-Utils.toInt(date.getTimezoneOffset() / 60) !==
491
530
  Utils.currUtcOffset());
492
- }
531
+ };
493
532
  /**
494
533
  * Determines if the given date is within DST in the given location
495
534
  * Note: This may not be correct if the user has set the Location to a
496
535
  * time zone outside Israel or the USA which is not the current system time zone.
497
536
  */
498
- static isDST(location, date) {
537
+ Utils.isDST = function (location, date) {
499
538
  //If the current system time zone is the same as the given locations time zone
500
539
  if (location.UTCOffset === Utils.currUtcOffset()) {
501
540
  //We can use the system data to determine if the given date is within DST
@@ -507,13 +546,13 @@ export class Utils {
507
546
  else {
508
547
  return Utils.isUSA_DST(date);
509
548
  }
510
- }
549
+ };
511
550
  /**
512
551
  * Determines if the given javascript date is during DST according to the USA rules
513
552
  * @param {Date} date A javascript Date object
514
553
  */
515
- static isUSA_DST(date) {
516
- const year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate(), hour = date.getHours();
554
+ Utils.isUSA_DST = function (date) {
555
+ var year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate(), hour = date.getHours();
517
556
  if (month < 3 || month == 12) {
518
557
  return false;
519
558
  }
@@ -524,7 +563,7 @@ export class Utils {
524
563
  else if (month === 3) {
525
564
  //March
526
565
  //Gets day of week on March 1st
527
- const firstDOW = Utils.getSdDOW(year, 3, 1),
566
+ var firstDOW = Utils.getSdDOW(year, 3, 1),
528
567
  //Gets date of second Sunday
529
568
  targetDate = firstDOW == 0 ? 8 : 7 - ((firstDOW + 7) % 7) + 8;
530
569
  return day > targetDate || (day === targetDate && hour >= 2);
@@ -532,19 +571,19 @@ export class Utils {
532
571
  //DST ends at 2 AM on the first Sunday in November //dt.Month == 11 / November
533
572
  else {
534
573
  //Gets day of week on November 1st
535
- const firstDOW = Utils.getSdDOW(year, 11, 1),
574
+ var firstDOW = Utils.getSdDOW(year, 11, 1),
536
575
  //Gets date of first Sunday
537
576
  targetDate = firstDOW === 0 ? 1 : 7 - ((firstDOW + 7) % 7) + 1;
538
577
  return day < targetDate || (day === targetDate && hour < 2);
539
578
  }
540
- }
579
+ };
541
580
  //
542
581
  /**
543
582
  * Determines if the given Javascript date is during DST according to the current (5776) Israeli rules
544
583
  * @param {Date} date A Javascript Date object
545
584
  */
546
- static isIsrael_DST(date) {
547
- const year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate(), hour = date.getHours();
585
+ Utils.isIsrael_DST = function (date) {
586
+ var year = date.getFullYear(), month = date.getMonth() + 1, day = date.getDate(), hour = date.getHours();
548
587
  if (month > 10 || month < 3) {
549
588
  return false;
550
589
  }
@@ -555,91 +594,91 @@ export class Utils {
555
594
  else if (month === 3) {
556
595
  //March
557
596
  //Gets date of the Friday before the last Sunday
558
- const lastFriday = 31 - Utils.getSdDOW(year, 3, 31) - 2;
597
+ var lastFriday = 31 - Utils.getSdDOW(year, 3, 31) - 2;
559
598
  return day > lastFriday || (day === lastFriday && hour >= 2);
560
599
  }
561
600
  //DST ends at 2 AM on the last Sunday in October //dt.Month === 10 / October
562
601
  else {
563
602
  //Gets date of last Sunday in October
564
- const lastSunday = 31 - Utils.getSdDOW(year, 10, 31);
603
+ var lastSunday = 31 - Utils.getSdDOW(year, 10, 31);
565
604
  return day < lastSunday || (day === lastSunday && hour < 2);
566
605
  }
567
- }
606
+ };
568
607
  /** The current time in Israel - determined by the current users system time and time zone offset*/
569
- static getSdNowInIsrael() {
570
- const now = new Date(),
608
+ Utils.getSdNowInIsrael = function () {
609
+ var now = new Date(),
571
610
  //first determine the hour differential between this user and Israel time
572
611
  israelTimeOffset = 2 + -Utils.currUtcOffset();
573
612
  //This will give us the current correct date and time in Israel
574
613
  now.setHours(now.getHours() + israelTimeOffset);
575
614
  return now;
576
- }
615
+ };
577
616
  /**
578
617
  * Adds the given number of days to the given javascript date and returns the new date
579
618
  * @param {Date} sdate
580
619
  * @param {Number} days
581
620
  */
582
- static addDaysToSdate(sdate, days) {
621
+ Utils.addDaysToSdate = function (sdate, days) {
583
622
  return new Date(sdate.valueOf() + 8.64e7 * days);
584
- }
623
+ };
585
624
  /**
586
625
  * Compares two js dates to se if they both refer to the same day - time is ignored.
587
626
  * @param {Date} sdate1
588
627
  * @param {Date} sdate2
589
628
  */
590
- static isSameSdate(sdate1, sdate2) {
629
+ Utils.isSameSdate = function (sdate1, sdate2) {
591
630
  return (sdate1 && sdate2 && sdate1.toDateString() === sdate2.toDateString());
592
- }
631
+ };
593
632
  /**
594
633
  * Compares two jDates to se if they both refer to the same day - time is ignored.
595
634
  * @param {jDate} jdate1
596
635
  * @param {jDate} jdate2
597
636
  */
598
- static isSameJdate(jdate1, jdate2) {
637
+ Utils.isSameJdate = function (jdate1, jdate2) {
599
638
  return (jdate1 &&
600
639
  jdate2 &&
601
640
  jdate1.Abs &&
602
641
  jdate2.Abs &&
603
642
  jdate1.Abs === jdate2.Abs);
604
- }
643
+ };
605
644
  /**
606
645
  * Compares two jDates to see if they both refer to the same Jewish Month.
607
646
  * @param {jDate} jdate1
608
647
  * @param {jDate} jdate2
609
648
  */
610
- static isSameJMonth(jdate1, jdate2) {
649
+ Utils.isSameJMonth = function (jdate1, jdate2) {
611
650
  return jdate1.Month === jdate2.Month && jdate1.Year === jdate2.Year;
612
- }
651
+ };
613
652
  /**
614
653
  * Compares two dates to se if they both refer to the same Secular Month.
615
654
  * @param {Date} sdate1
616
655
  * @param {Date} sdate2
617
656
  */
618
- static isSameSMonth(sdate1, sdate2) {
657
+ Utils.isSameSMonth = function (sdate1, sdate2) {
619
658
  return (sdate1.getMonth() === sdate2.getMonth() &&
620
659
  sdate1.getFullYear() === sdate2.getFullYear());
621
- }
660
+ };
622
661
  /**
623
662
  * Determines if the time of the given Date() is after sunset at the given Location
624
663
  * @param {Date} sdate
625
664
  * @param {Location} location
626
665
  */
627
- static isAfterSunset(sdate, location) {
628
- const shkia = Zmanim.getSunTimes(sdate, location).sunset, now = Utils.timeFromDate(sdate);
666
+ Utils.isAfterSunset = function (sdate, location) {
667
+ var shkia = Zmanim.getSunTimes(sdate, location).sunset, now = Utils.timeFromDate(sdate);
629
668
  return shkia && Utils.isTimeAfter(shkia, now);
630
- }
669
+ };
631
670
  /**
632
671
  * Gets the current Jewish Date at the given Location
633
672
  * @param {Location} location
634
673
  */
635
- static nowAtLocation(location) {
636
- let sdate = new Date();
674
+ Utils.nowAtLocation = function (location) {
675
+ var sdate = new Date();
637
676
  //if isAfterSunset a day is added.
638
677
  if (Utils.isAfterSunset(sdate, location)) {
639
678
  sdate.setDate(sdate.getDate() + 1);
640
679
  }
641
680
  return new jDate(sdate);
642
- }
681
+ };
643
682
  /**
644
683
  * Converts the given complex number to an integer by removing the decimal part.
645
684
  * Returns same results as Math.floor for positive numbers and Math.ceil for negative ones.
@@ -648,46 +687,50 @@ export class Utils {
648
687
  * In performance tests, this function was found to be quicker than the alternatives.
649
688
  * @param {Number} float The complex number to convert to an integer
650
689
  */
651
- static toInt(float) {
690
+ Utils.toInt = function (float) {
652
691
  return float | 0;
653
- }
692
+ };
654
693
  /***
655
694
  * Takes either a jDate or a Date and returns both
656
695
  * @param date {Date |jDate}
657
696
  * @returns {{ sdate:Date, jdate:jDate }}
658
697
  */
659
- static bothDates(date) {
660
- const jdate = date instanceof Date
698
+ Utils.bothDates = function (date) {
699
+ var jdate = date instanceof Date
661
700
  ? new jDate(date)
662
701
  : date;
663
- const sdate = date instanceof Date
702
+ var sdate = date instanceof Date
664
703
  ? date
665
704
  : jdate.getDate();
666
- return { sdate, jdate };
667
- }
705
+ return { sdate: sdate, jdate: jdate };
706
+ };
668
707
  /** Returns true if "thing" is either a string primitive or String object.*/
669
- static isString(thing) {
708
+ Utils.isString = function (thing) {
670
709
  return typeof thing === 'string' || thing instanceof String;
671
- }
710
+ };
672
711
  /** Returns true if "thing" is either a number primitive or a Number object.*/
673
- static isNumber(thing) {
712
+ Utils.isNumber = function (thing) {
674
713
  return typeof thing === 'number' || thing instanceof Number;
675
- }
714
+ };
676
715
  /** Returns true if "thing" is a Date object containing a valid date.*/
677
- static isValidDate(thing) {
716
+ Utils.isValidDate = function (thing) {
678
717
  return thing instanceof Date && !isNaN(thing.valueOf());
679
- }
718
+ };
680
719
  /** Returns whether or not the given, array, string, or argument list contains the given item or substring.
681
720
  *
682
721
  * This function is awfully similar to Array.includes, but has the added plus of accepting any number or type of arguments.*/
683
- static has(o, ...arr) {
722
+ Utils.has = function (o) {
723
+ var arr = [];
724
+ for (var _i = 1; _i < arguments.length; _i++) {
725
+ arr[_i - 1] = arguments[_i];
726
+ }
684
727
  if (arr.length === 1 && (Array.isArray(arr[0]) || Utils.isString(arr[0]))) {
685
728
  return arr[0].includes(o);
686
729
  }
687
730
  else {
688
731
  return arr.includes(o);
689
732
  }
690
- }
733
+ };
691
734
  /** Returns the first value unless it is undefined, null or NaN.
692
735
  *
693
736
  * This is very useful for boolean, string and integer parameters
@@ -696,7 +739,7 @@ export class Utils {
696
739
  * Similar purpose to default parameters with the difference being that this function will return
697
740
  * the second value if the first is NaN or null, while default params will give give you the NaN or the null.
698
741
  */
699
- static setDefault(paramValue, defValue) {
742
+ Utils.setDefault = function (paramValue, defValue) {
700
743
  if (typeof paramValue === 'undefined' ||
701
744
  paramValue === null ||
702
745
  isNaN(paramValue)) {
@@ -705,7 +748,7 @@ export class Utils {
705
748
  else {
706
749
  return paramValue;
707
750
  }
708
- }
751
+ };
709
752
  /**
710
753
  * Returns an array containing a range of integers.
711
754
  * @param {Number} [start] The number to start at. The start number is included in the results.
@@ -714,52 +757,66 @@ export class Utils {
714
757
  * Unlike Pythons range function, The end number is included in the results.
715
758
  * @returns {[Number]}
716
759
  */
717
- static range(start, end) {
718
- const startNumber = typeof (end) === 'undefined' ? 1 : start, endNumber = typeof (end) === 'undefined' ? start : end;
719
- return Array.from({ length: endNumber - startNumber + 1 }, (v, i) => startNumber + i);
720
- }
760
+ Utils.range = function (start, end) {
761
+ var startNumber = typeof (end) === 'undefined' ? 1 : start, endNumber = typeof (end) === 'undefined' ? start : end;
762
+ return Array.from({ length: endNumber - startNumber + 1 }, function (v, i) { return startNumber + i; });
763
+ };
721
764
  /**
722
765
  * Log message to console
723
766
  * @param {string} txt
724
767
  */
725
- static log(txt, ...optionalItems) {
768
+ Utils.log = function (txt) {
769
+ var optionalItems = [];
770
+ for (var _i = 1; _i < arguments.length; _i++) {
771
+ optionalItems[_i - 1] = arguments[_i];
772
+ }
726
773
  if (__DEV__) {
727
- console.log(txt, ...optionalItems);
774
+ console.log.apply(console, __spreadArray([txt], __read(optionalItems), false));
728
775
  }
729
- }
776
+ };
730
777
  /**
731
778
  * Warn message to console
732
779
  * @param {string} txt
733
780
  */
734
- static warn(txt, ...optionalItems) {
781
+ Utils.warn = function (txt) {
782
+ var optionalItems = [];
783
+ for (var _i = 1; _i < arguments.length; _i++) {
784
+ optionalItems[_i - 1] = arguments[_i];
785
+ }
735
786
  if (__DEV__) {
736
- console.warn(txt, ...optionalItems);
787
+ console.warn.apply(console, __spreadArray([txt], __read(optionalItems), false));
737
788
  }
738
- }
789
+ };
739
790
  /**
740
791
  * Error message to console
741
792
  * @param {*} txt
742
793
  */
743
- static error(txt, ...optionalItems) {
744
- if (__DEV__) {
745
- console.error(txt, ...optionalItems);
794
+ Utils.error = function (txt) {
795
+ var optionalItems = [];
796
+ for (var _i = 1; _i < arguments.length; _i++) {
797
+ optionalItems[_i - 1] = arguments[_i];
746
798
  }
747
- }
748
- }
749
- Utils.jsd = ['א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט'];
750
- Utils.jtd = ['י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ'];
751
- Utils.jhd = ['ק', 'ר', 'ש', 'ת'];
752
- Utils.jsnum = [
753
- '',
754
- 'אחד',
755
- 'שנים',
756
- 'שלשה',
757
- 'ארבעה',
758
- 'חמשה',
759
- 'ששה',
760
- 'שבעה',
761
- 'שמונה',
762
- 'תשעה',
763
- ];
764
- Utils.jtnum = ['', 'עשר', 'עשרים', 'שלושים', 'ארבעים'];
799
+ if (__DEV__) {
800
+ console.error.apply(console, __spreadArray([txt], __read(optionalItems), false));
801
+ }
802
+ };
803
+ Utils.jsd = ['א', 'ב', 'ג', 'ד', 'ה', 'ו', 'ז', 'ח', 'ט'];
804
+ Utils.jtd = ['י', 'כ', 'ל', 'מ', 'נ', 'ס', 'ע', 'פ', 'צ'];
805
+ Utils.jhd = ['ק', 'ר', 'ש', 'ת'];
806
+ Utils.jsnum = [
807
+ '',
808
+ 'אחד',
809
+ 'שנים',
810
+ 'שלשה',
811
+ 'ארבעה',
812
+ 'חמשה',
813
+ 'ששה',
814
+ 'שבעה',
815
+ 'שמונה',
816
+ 'תשעה',
817
+ ];
818
+ Utils.jtnum = ['', 'עשר', 'עשרים', 'שלושים', 'ארבעים'];
819
+ return Utils;
820
+ }());
821
+ export { Utils };
765
822
  //# sourceMappingURL=Utils.js.map