-
Notifications
You must be signed in to change notification settings - Fork 14
/
JewishCalendar.ts
1179 lines (1047 loc) · 58.4 KB
/
JewishCalendar.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { DateTime } from 'luxon';
import { GeoLocation } from '../util/GeoLocation';
import { Daf } from './Daf';
import { JewishDate } from './JewishDate';
import { Calendar } from '../polyfills/Utils';
import { UnsupportedError } from '../polyfills/errors';
const { MONDAY, TUESDAY, THURSDAY, FRIDAY, SATURDAY } = Calendar;
/**
* List of <em>parshiyos</em>. {@link #NONE} indicates a week without a <em>parsha</em>, while the enum for the <em>parsha</em> of
* {@link #VZOS_HABERACHA} exists for consistency, but is not currently used.
*
*/
export enum Parsha {
/** NONE - A week without any <em>parsha</em> such as <em>Shabbos Chol Hamoed</em> */
NONE,
BERESHIS, NOACH, LECH_LECHA, VAYERA, CHAYEI_SARA, TOLDOS, VAYETZEI,
VAYISHLACH, VAYESHEV, MIKETZ, VAYIGASH, VAYECHI, SHEMOS, VAERA, BO,
BESHALACH, YISRO, MISHPATIM, TERUMAH, TETZAVEH, KI_SISA, VAYAKHEL,
PEKUDEI, VAYIKRA, TZAV, SHMINI, TAZRIA, METZORA, ACHREI_MOS, KEDOSHIM,
EMOR, BEHAR, BECHUKOSAI, BAMIDBAR, NASSO, BEHAALOSCHA, SHLACH, KORACH,
CHUKAS, BALAK, PINCHAS, MATOS, MASEI, DEVARIM, VAESCHANAN, EIKEV,
REEH, SHOFTIM, KI_SEITZEI, KI_SAVO, NITZAVIM, VAYEILECH, HAAZINU,
VZOS_HABERACHA,
/** The double parsha of Vayakhel & Peudei */
VAYAKHEL_PEKUDEI,
/** The double <em>parsha</em> of Tazria & Metzora */
TAZRIA_METZORA,
/** The double <em>parsha</em> of Achrei Mos & Kedoshim */
ACHREI_MOS_KEDOSHIM,
/** The double <em>parsha</em> of Behar & Bechukosai */
BEHAR_BECHUKOSAI,
/** The double <em>parsha</em> of Chukas & Balak */
CHUKAS_BALAK,
/** The double <em>parsha</em> of Matos & Masei */
MATOS_MASEI,
/** The double <em>parsha</em> of Nitzavim & Vayelech */
NITZAVIM_VAYEILECH,
/** The special <em>parsha</em> of Shekalim */
SHKALIM,
/** The special <em>parsha</em> of Zachor */
ZACHOR,
/** The special <em>parsha</em> of Para */
PARA,
/** The special <em>parsha</em> of Hachodesh */
HACHODESH,
}
/**
* The JewishCalendar extends the JewishDate class and adds calendar methods.
*
* This open source Java code was originally ported by <a href="http://www.facebook.com/avromf">Avrom Finkelstien</a>
* from his C++ code. It was refactored to fit the KosherJava Zmanim API with simplification of the code, enhancements
* and some bug fixing. The class allows setting whether the holiday and parsha scheme follows the Israel scheme or outside Israel
* scheme. The default is the outside Israel scheme.
* The parsha code was ported by Y. Paritcher from his <a href="https://github.com/yparitcher/libzmanim">libzmanim</a> code.
*
* TODO: Some do not belong in this class, but here is a partial list of what should still be implemented in some form:
* <ol>
* <li>Add Isru Chag</li>
* <li>Mishna yomis etc</li>
* </ol>
*
* @see java.util.Date
* @see java.util.Calendar
* @author © Y. Paritcher 2019
* @author © Avrom Finkelstien 2002
* @author © Eliyahu Hershfeld 2011 - 2019
*/
export class JewishCalendar extends JewishDate {
/** The 14th day of Nisan, the day before of Pesach (Passover). */
public static readonly EREV_PESACH: number = 0;
/** The holiday of Pesach (Passover) on the 15th (and 16th out of Israel) day of Nisan. */
public static readonly PESACH: number = 1;
/** Chol Hamoed (interim days) of Pesach (Passover) */
public static readonly CHOL_HAMOED_PESACH: number = 2;
/** Pesach Sheni, the 14th day of Iyar, a minor holiday. */
public static readonly PESACH_SHENI: number = 3;
/** Erev Shavuos (the day before Shavuos), the 5th of Sivan */
public static readonly EREV_SHAVUOS: number = 4;
/** Shavuos (Pentecost), the 6th of Sivan */
public static readonly SHAVUOS: number = 5;
/** The fast of the 17th day of Tamuz */
public static readonly SEVENTEEN_OF_TAMMUZ: number = 6;
/** The fast of the 9th of Av */
public static readonly TISHA_BEAV: number = 7;
/** The 15th day of Av, a minor holiday */
public static readonly TU_BEAV: number = 8;
/** Erev Rosh Hashana (the day before Rosh Hashana), the 29th of Elul */
public static readonly EREV_ROSH_HASHANA: number = 9;
/** Rosh Hashana, the first of Tishrei. */
public static readonly ROSH_HASHANA: number = 10;
/** The fast of Gedalyah, the 3rd of Tishrei. */
public static readonly FAST_OF_GEDALYAH: number = 11;
/** The 9th day of Tishrei, the day before of Yom Kippur. */
public static readonly EREV_YOM_KIPPUR: number = 12;
/** The holiday of Yom Kippur, the 10th day of Tishrei */
public static readonly YOM_KIPPUR: number = 13;
/** The 14th day of Tishrei, the day before of Succos/Sukkos (Tabernacles). */
public static readonly EREV_SUCCOS: number = 14;
/** The holiday of Succos/Sukkos (Tabernacles), the 15th (and 16th out of Israel) day of Tishrei */
public static readonly SUCCOS: number = 15;
/** Chol Hamoed (interim days) of Succos/Sukkos (Tabernacles) */
public static readonly CHOL_HAMOED_SUCCOS: number = 16;
/** Hoshana Rabba, the 7th day of Succos/Sukkos that occurs on the 21st of Tishrei. */
public static readonly HOSHANA_RABBA: number = 17;
/** Shmini Atzeres, the 8th day of Succos/Sukkos is an independent holiday that occurs on the 22nd of Tishrei. */
public static readonly SHEMINI_ATZERES: number = 18;
/** Simchas Torah, the 9th day of Succos/Sukkos, or the second day of Shmini Atzeres that is celebrated
* {@link #getInIsrael() out of Israel} on the 23rd of Tishrei.
*/
public static readonly SIMCHAS_TORAH: number = 19;
// public static final int EREV_CHANUKAH = 20;// probably remove this
/** The holiday of Chanukah. 8 days starting on the 25th day Kislev. */
public static readonly CHANUKAH: number = 21;
/** The fast of the 10th day of Teves. */
public static readonly TENTH_OF_TEVES: number = 22;
/** Tu Bishvat on the 15th day of Shevat, a minor holiday. */
public static readonly TU_BESHVAT: number = 23;
/** The fast of Esther, usually on the 13th day of Adar (or Adar II on leap years). It is earlier on some years. */
public static readonly FAST_OF_ESTHER: number = 24;
/** The holiday of Purim on the 14th day of Adar (or Adar II on leap years). */
public static readonly PURIM: number = 25;
/** The holiday of Shushan Purim on the 15th day of Adar (or Adar II on leap years). */
public static readonly SHUSHAN_PURIM: number = 26;
/** The holiday of Purim Katan on the 14th day of Adar I on a leap year when Purim is on Adar II, a minor holiday. */
public static readonly PURIM_KATAN: number = 27;
/**
* Rosh Chodesh, the new moon on the first day of the Jewish month, and the 30th day of the previous month in the
* case of a month with 30 days.
*/
public static readonly ROSH_CHODESH: number = 28;
/** Yom HaShoah, Holocaust Remembrance Day, usually held on the 27th of Nisan. If it falls on a Friday, it is moved
* to the 26th, and if it falls on a Sunday it is moved to the 28th. A {@link #isUseModernHolidays() modern holiday}.
*/
public static readonly YOM_HASHOAH: number = 29;
/**
* Yom HaZikaron, Israeli Memorial Day, held a day before Yom Ha'atzmaut. A {@link #isUseModernHolidays() modern holiday}.
*/
public static readonly YOM_HAZIKARON: number = 30;
/** Yom Ha'atzmaut, Israel Independence Day, the 5th of Iyar, but if it occurs on a Friday or Saturday, the holiday is
* moved back to Thursday, the 3rd of 4th of Iyar, and if it falls on a Monday, it is moved forward to Tuesday the
* 6th of Iyar. A {@link #isUseModernHolidays() modern holiday}. */
public static readonly YOM_HAATZMAUT: number = 31;
/**
* Yom Yerushalayim or Jerusalem Day, on 28 Iyar. A {@link #isUseModernHolidays() modern holiday}.
*/
public static readonly YOM_YERUSHALAYIM: number = 32;
/** The 33rd day of the Omer, the 18th of Iyar, a minor holiday. */
public static readonly LAG_BAOMER: number = 33;
/** The holiday of Purim Katan on the 15th day of Adar I on a leap year when Purim is on Adar II, a minor holiday. */
public static readonly SHUSHAN_PURIM_KATAN: number = 34;
/**
* Is the calendar set to Israel, where some holidays have different rules.
* @see #getInIsrael()
* @see #setInIsrael(boolean)
*/
private inIsrael: boolean = false;
/**
* Is the calendar set to use modern Israeli holidays such as Yom Haatzmaut.
* @see #isUseModernHolidays()
* @see #setUseModernHolidays(boolean)
*/
private useModernHolidays: boolean = false;
/**
* An array of <em>parshiyos</em> in the 17 possible combinations.
*/
public static readonly parshalist: Parsha[][] = [
[Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
[Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NONE, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS_BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
[Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM],
[Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM],
[Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM],
[Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
[Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NONE, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS_BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
[Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM],
[Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.ACHREI_MOS, Parsha.NONE, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS, Parsha.MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM],
[Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.ACHREI_MOS, Parsha.NONE, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS, Parsha.MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
[Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
[Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NONE, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS_BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
[Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR_BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
[Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL_PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.NONE, Parsha.SHMINI, Parsha.TAZRIA_METZORA, Parsha.ACHREI_MOS_KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM],
[Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
[Parsha.NONE, Parsha.VAYEILECH, Parsha.HAAZINU, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS, Parsha.MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM],
[Parsha.NONE, Parsha.NONE, Parsha.HAAZINU, Parsha.NONE, Parsha.NONE, Parsha.BERESHIS, Parsha.NOACH, Parsha.LECH_LECHA, Parsha.VAYERA, Parsha.CHAYEI_SARA, Parsha.TOLDOS, Parsha.VAYETZEI, Parsha.VAYISHLACH, Parsha.VAYESHEV, Parsha.MIKETZ, Parsha.VAYIGASH, Parsha.VAYECHI, Parsha.SHEMOS, Parsha.VAERA, Parsha.BO, Parsha.BESHALACH, Parsha.YISRO, Parsha.MISHPATIM, Parsha.TERUMAH, Parsha.TETZAVEH, Parsha.KI_SISA, Parsha.VAYAKHEL, Parsha.PEKUDEI, Parsha.VAYIKRA, Parsha.TZAV, Parsha.SHMINI, Parsha.TAZRIA, Parsha.METZORA, Parsha.NONE, Parsha.ACHREI_MOS, Parsha.KEDOSHIM, Parsha.EMOR, Parsha.BEHAR, Parsha.BECHUKOSAI, Parsha.BAMIDBAR, Parsha.NASSO, Parsha.BEHAALOSCHA, Parsha.SHLACH, Parsha.KORACH, Parsha.CHUKAS, Parsha.BALAK, Parsha.PINCHAS, Parsha.MATOS_MASEI, Parsha.DEVARIM, Parsha.VAESCHANAN, Parsha.EIKEV, Parsha.REEH, Parsha.SHOFTIM, Parsha.KI_SEITZEI, Parsha.KI_SAVO, Parsha.NITZAVIM_VAYEILECH],
];
/**
* Is this calendar set to return modern Israeli national holidays. By default this value is false. The holidays
* are: "Yom HaShoah", "Yom Hazikaron", "Yom Ha'atzmaut" and "Yom Yerushalayim"
*
* @return the useModernHolidays true if set to return modern Israeli national holidays
*/
public isUseModernHolidays(): boolean {
return this.useModernHolidays;
}
/**
* Seth the calendar to return modern Israeli national holidays. By default this value is false. The holidays are:
* "Yom HaShoah", "Yom Hazikaron", "Yom Ha'atzmaut" and "Yom Yerushalayim"
*
* @param useModernHolidays
* the useModernHolidays to set
*/
public setUseModernHolidays(useModernHolidays: boolean): void {
this.useModernHolidays = useModernHolidays;
}
/**
* Default constructor will set a default date to the current system date.
*/
/*
public JewishCalendar() {
super();
}
*/
/**
* A constructor that initializes the date to the {@link java.util.Date Date} parameter.
*
* @param date
* the <code>Date</code> to set the calendar to
*/
/*
public JewishCalendar(date: Date) {
super(date);
}
*/
/**
* A constructor that initializes the date to the {@link java.util.Calendar Calendar} parameter.
*
* @param calendar
* the <code>Calendar</code> to set the calendar to
*/
/*
public JewishCalendar(calendar: GregorianCalendar) {
super(calendar);
}
*/
/**
* Creates a Jewish date based on a Jewish year, month and day of month.
*
* @param jewishYear
* the Jewish year
* @param jewishMonth
* the Jewish month. The method expects a 1 for Nissan ... 12 for Adar and 13 for Adar II. Use the
* constants {@link #NISSAN} ... {@link #ADAR} (or {@link #ADAR_II} for a leap year Adar II) to avoid any
* confusion.
* @param jewishDayOfMonth
* the Jewish day of month. If 30 is passed in for a month with only 29 days (for example {@link #IYAR},
* or {@link #KISLEV} in a year that {@link #isKislevShort()}), the 29th (last valid date of the month)
* will be set
* @throws IllegalArgumentException
* if the day of month is < 1 or > 30, or a year of < 0 is passed in.
*/
/*
public JewishCalendar(jewishYear: number, jewishMonth: number, jewishDayOfMonth: number) {
super(jewishYear, jewishMonth, jewishDayOfMonth);
}
*/
/**
* Creates a Jewish date based on a Jewish date and whether in Israel
*
* @param jewishYear
* the Jewish year
* @param jewishMonth
* the Jewish month. The method expects a 1 for Nissan ... 12 for Adar and 13 for Adar II. Use the
* constants {@link #NISSAN} ... {@link #ADAR} (or {@link #ADAR_II} for a leap year Adar II) to avoid any
* confusion.
* @param jewishDayOfMonth
* the Jewish day of month. If 30 is passed in for a month with only 29 days (for example {@link #IYAR},
* or {@link #KISLEV} in a year that {@link #isKislevShort()}), the 29th (last valid date of the month)
* will be set
* @param inIsrael
* whether in Israel. This affects Yom Tov calculations
*/
constructor(jewishYear: number, jewishMonth: number, jewishDayOfMonth: number, inIsrael?: boolean)
constructor(date: Date)
constructor(date: DateTime)
constructor()
constructor(jewishYearOrDateTimeOrDate?: number | Date | DateTime, jewishMonth?: number, jewishDayOfMonth?: number, inIsrael?: boolean) {
// @ts-ignore
super(jewishYearOrDateTimeOrDate, jewishMonth, jewishDayOfMonth);
if (inIsrael) this.setInIsrael(inIsrael);
}
/**
* Sets whether to use Israel holiday scheme or not. Default is false.
*
* @param inIsrael
* set to true for calculations for Israel
*/
public setInIsrael(inIsrael: boolean): void {
this.inIsrael = inIsrael;
}
/**
* Gets whether Israel holiday scheme is used or not. The default (if not set) is false.
*
* @return if the if the calendar is set to Israel
*/
public getInIsrael(): boolean {
return this.inIsrael;
}
/**
* <a href="https://en.wikipedia.org/wiki/Birkat_Hachama">Birkas Hachamah</a> is recited every 28 years based on
* Tekufas Shmulel (Julian years) that a year is 365.25 days. The <a href="https://en.wikipedia.org/wiki/Maimonides">Rambam</a>
* in <a href="http://hebrewbooks.org/pdfpager.aspx?req=14278&st=&pgnum=323">Hilchos Kiddush Hachodesh 9:3</a> states that
* tekufas Nisan of year 1 was 7 days + 9 hours before molad Nisan. This is calculated as every 10,227 days (28 * 365.25).
* @return true for a day that Birkas Hachamah is recited.
*/
public isBirkasHachamah(): boolean {
// elapsed days since molad ToHu
let elapsedDays: number = JewishCalendar.getJewishCalendarElapsedDays(this.getJewishYear());
// elapsed days to the current calendar date
elapsedDays += this.getDaysSinceStartOfJewishYear();
/* Molad Nisan year 1 was 177 days after molad tohu of Tishrei. We multiply 29.5 day months * 6 months from Tishrei
* to Nisan = 177. Subtract 7 days since tekufas Nisan was 7 days and 9 hours before the molad as stated in the Rambam
* and we are now at 170 days. Because getJewishCalendarElapsedDays and getDaysSinceStartOfJewishYear use the value for
* Rosh Hashana as 1, we have to add 1 day days for a total of 171. To this add a day since the tekufah is on a Tuesday
* night and we push off the bracha to Wednesday AM resulting in the 172 used in the calculation.
*/
// 28 years of 365.25 days + the offset from molad tohu mentioned above
return elapsedDays % (28 * 365.25) === 172;
}
/**
* Return the type of year for parsha calculations. The algorithm follows the
* <a href="http://hebrewbooks.org/pdfpager.aspx?req=14268&st=&pgnum=222">Luach Arba'ah Shearim</a> in the Tur Ohr Hachaim.
* @return the type of year for parsha calculations.
* @todo Use constants in this class.
*/
private getParshaYearType(): number {
// plus one to the original Rosh Hashana of year 1 to get a week starting on Sunday
let roshHashanaDayOfWeek: number = (JewishCalendar.getJewishCalendarElapsedDays(this.getJewishYear()) + 1) % 7;
if (roshHashanaDayOfWeek === 0) {
// convert 0 to 7 for Shabbos for readability
roshHashanaDayOfWeek = SATURDAY;
}
if (this.isJewishLeapYear()) {
// eslint-disable-next-line default-case
switch (roshHashanaDayOfWeek) {
case MONDAY:
// BaCh
if (this.isKislevShort()) {
if (this.getInIsrael()) {
return 14;
}
return 6;
}
// BaSh
if (this.isCheshvanLong()) {
if (this.getInIsrael()) {
return 15;
}
return 7;
}
break;
// GaK
case TUESDAY:
if (this.getInIsrael()) {
return 15;
}
return 7;
case THURSDAY:
// HaCh
if (this.isKislevShort()) {
return 8;
}
// HaSh
if (this.isCheshvanLong()) {
return 9;
}
break;
case SATURDAY:
// ZaCh
if (this.isKislevShort()) {
return 10;
}
// ZaSh
if (this.isCheshvanLong()) {
if (this.getInIsrael()) {
return 16;
}
return 11;
}
break;
}
} else {
// not a leap year
// eslint-disable-next-line default-case
switch (roshHashanaDayOfWeek) {
case MONDAY:
// BaCh
if (this.isKislevShort()) {
return 0;
}
// BaSh
if (this.isCheshvanLong()) {
if (this.getInIsrael()) {
return 12;
}
return 1;
}
break;
case TUESDAY:
// GaK
if (this.getInIsrael()) {
return 12;
}
return 1;
case THURSDAY:
// HaSh
if (this.isCheshvanLong()) {
return 3;
}
// HaK
if (!this.isKislevShort()) {
if (this.getInIsrael()) {
return 13;
}
return 2;
}
break;
case SATURDAY:
// ZaCh
if (this.isKislevShort()) {
return 4;
}
// ZaSh
if (this.isCheshvanLong()) {
return 5;
}
break;
}
}
// keep the compiler happy
return -1;
}
/**
* Returns this week's {@link Parsha} if it is Shabbos.
* returns Parsha.NONE if a weekday or if there is no parsha that week (for example Yomtov is on Shabbos)
* @return the current parsha
*/
public getParsha(): Parsha {
if (this.getDayOfWeek() !== SATURDAY) {
return Parsha.NONE;
}
const yearType: number = this.getParshaYearType();
const roshHashanaDayOfWeek: number = JewishCalendar.getJewishCalendarElapsedDays(this.getJewishYear()) % 7;
const day: number = roshHashanaDayOfWeek + this.getDaysSinceStartOfJewishYear();
// negative year should be impossible, but lets cover all bases
if (yearType >= 0) {
return JewishCalendar.parshalist[yearType][day / 7];
}
// keep the compiler happy
return Parsha.NONE;
}
/**
* Returns a parsha enum if the Shabbos is one of the four parshiyos of Parsha.SHKALIM, Parsha.ZACHOR, Parsha.PARA,
* Parsha.HACHODESH or Parsha.NONE for a regular Shabbos (or any weekday).
* @return one of the four parshiyos of Parsha.SHKALIM, Parsha.ZACHOR, Parsha.PARA, Parsha.HACHODESH or Parsha.NONE.
*/
public getSpecialShabbos(): Parsha {
if (this.getDayOfWeek() === SATURDAY) {
if (((this.getJewishMonth() === JewishCalendar.SHEVAT && !this.isJewishLeapYear())
|| (this.getJewishMonth() === JewishCalendar.ADAR && this.isJewishLeapYear()))
&& [25, 27, 29].includes(this.getJewishDayOfMonth())) {
return Parsha.SHKALIM;
}
if ((this.getJewishMonth() === JewishCalendar.ADAR && !this.isJewishLeapYear())
|| this.getJewishMonth() === JewishCalendar.ADAR_II) {
if (this.getJewishDayOfMonth() === 1) {
return Parsha.SHKALIM;
}
if ([8, 9, 11, 13].includes(this.getJewishDayOfMonth())) {
return Parsha.ZACHOR;
}
if ([18, 20, 22, 23].includes(this.getJewishDayOfMonth())) {
return Parsha.PARA;
}
if ([25, 27, 29].includes(this.getJewishDayOfMonth())) {
return Parsha.HACHODESH;
}
}
if (this.getJewishMonth() === JewishCalendar.NISSAN && this.getJewishDayOfMonth() === 1) {
return Parsha.HACHODESH;
}
}
return Parsha.NONE;
}
/**
* Returns an index of the Jewish holiday or fast day for the current day, or a -1 if there is no holiday for this
* day. There are constants in this class representing each Yom Tov. Formatting of the Yomim tovim is done in the
* ZmanimFormatter#
*
* @todo consider using enums instead of the constant ints.
*
* @return the index of the holiday such as the constant {@link #LAG_BAOMER} or {@link #YOM_KIPPUR} or a -1 if it is not a holiday.
* @see HebrewDateFormatter
*/
public getYomTovIndex(): number {
const day: number = this.getJewishDayOfMonth();
const dayOfWeek: number = this.getDayOfWeek();
// check by month (starting from Nissan)
// eslint-disable-next-line default-case
switch (this.getJewishMonth()) {
case JewishCalendar.NISSAN:
if (day === 14) {
return JewishCalendar.EREV_PESACH;
} else if (day === 15 || day === 21 || (!this.inIsrael && (day === 16 || day === 22))) {
return JewishCalendar.PESACH;
} else if ((day >= 17 && day <= 20) || (day === 16 && this.inIsrael)) {
return JewishCalendar.CHOL_HAMOED_PESACH;
}
if (this.isUseModernHolidays()
&& ((day === 26 && dayOfWeek === 5) || (day === 28 && dayOfWeek === 2)
|| (day === 27 && dayOfWeek !== 1 && dayOfWeek !== 6))) {
return JewishCalendar.YOM_HASHOAH;
}
break;
case JewishCalendar.IYAR:
if (this.isUseModernHolidays()
&& ((day === 4 && dayOfWeek === 3) || ((day === 3 || day === 2) && dayOfWeek === 4)
|| (day === 5 && dayOfWeek === 2))) {
return JewishCalendar.YOM_HAZIKARON;
}
// if 5 Iyar falls on Wed Yom Haatzmaut is that day. If it fal1s on Friday or Shabbos it is moved back to
// Thursday. If it falls on Monday it is moved to Tuesday
if (this.isUseModernHolidays() && ((day === 5 && dayOfWeek === 4)
|| ((day === 4 || day === 3) && dayOfWeek === 5) || (day === 6 && dayOfWeek === 3))) {
return JewishCalendar.YOM_HAATZMAUT;
}
if (day === 14) {
return JewishCalendar.PESACH_SHENI;
}
if (day === 18) {
return JewishCalendar.LAG_BAOMER;
}
if (this.isUseModernHolidays() && day === 28) {
return JewishCalendar.YOM_YERUSHALAYIM;
}
break;
case JewishCalendar.SIVAN:
if (day === 5) {
return JewishCalendar.EREV_SHAVUOS;
} else if (day === 6 || (day === 7 && !this.inIsrael)) {
return JewishCalendar.SHAVUOS;
}
break;
case JewishCalendar.TAMMUZ:
// push off the fast day if it falls on Shabbos
if ((day === 17 && dayOfWeek !== 7) || (day === 18 && dayOfWeek === 1)) {
return JewishCalendar.SEVENTEEN_OF_TAMMUZ;
}
break;
case JewishCalendar.AV:
// if Tisha B'av falls on Shabbos, push off until Sunday
if ((dayOfWeek === 1 && day === 10) || (dayOfWeek !== 7 && day === 9)) {
return JewishCalendar.TISHA_BEAV;
} else if (day === 15) {
return JewishCalendar.TU_BEAV;
}
break;
case JewishCalendar.ELUL:
if (day === 29) {
return JewishCalendar.EREV_ROSH_HASHANA;
}
break;
case JewishCalendar.TISHREI:
if (day === 1 || day === 2) {
return JewishCalendar.ROSH_HASHANA;
} else if ((day === 3 && dayOfWeek !== 7) || (day === 4 && dayOfWeek === 1)) {
// push off Tzom Gedalia if it falls on Shabbos
return JewishCalendar.FAST_OF_GEDALYAH;
} else if (day === 9) {
return JewishCalendar.EREV_YOM_KIPPUR;
} else if (day === 10) {
return JewishCalendar.YOM_KIPPUR;
} else if (day === 14) {
return JewishCalendar.EREV_SUCCOS;
}
if (day === 15 || (day === 16 && !this.inIsrael)) {
return JewishCalendar.SUCCOS;
}
if ((day >= 17 && day <= 20) || (day === 16 && this.inIsrael)) {
return JewishCalendar.CHOL_HAMOED_SUCCOS;
}
if (day === 21) {
return JewishCalendar.HOSHANA_RABBA;
}
if (day === 22) {
return JewishCalendar.SHEMINI_ATZERES;
}
if (day === 23 && !this.inIsrael) {
return JewishCalendar.SIMCHAS_TORAH;
}
break;
case JewishCalendar.KISLEV: // no yomtov in CHESHVAN
// if (day == 24) {
// return EREV_CHANUKAH;
// } else
if (day >= 25) {
return JewishCalendar.CHANUKAH;
}
break;
case JewishCalendar.TEVES:
if (day === 1 || day === 2 || (day === 3 && this.isKislevShort())) {
return JewishCalendar.CHANUKAH;
} else if (day === 10) {
return JewishCalendar.TENTH_OF_TEVES;
}
break;
case JewishCalendar.SHEVAT:
if (day === 15) {
return JewishCalendar.TU_BESHVAT;
}
break;
case JewishCalendar.ADAR:
if (!this.isJewishLeapYear()) {
// if 13th Adar falls on Friday or Shabbos, push back to Thursday
if (((day === 11 || day === 12) && dayOfWeek === 5) || (day === 13 && !(dayOfWeek === 6 || dayOfWeek === 7))) {
return JewishCalendar.FAST_OF_ESTHER;
}
if (day === 14) {
return JewishCalendar.PURIM;
} else if (day === 15) {
return JewishCalendar.SHUSHAN_PURIM;
}
} else {
// else if a leap year
if (day === 14) {
return JewishCalendar.PURIM_KATAN;
}
if (day === 15) {
return JewishCalendar.SHUSHAN_PURIM_KATAN;
}
}
break;
case JewishCalendar.ADAR_II:
// if 13th Adar falls on Friday or Shabbos, push back to Thursday
if (((day === 11 || day === 12) && dayOfWeek === 5) || (day === 13 && !(dayOfWeek === 6 || dayOfWeek === 7))) {
return JewishCalendar.FAST_OF_ESTHER;
}
if (day === 14) {
return JewishCalendar.PURIM;
} else if (day === 15) {
return JewishCalendar.SHUSHAN_PURIM;
}
break;
}
// if we get to this stage, then there are no holidays for the given date return -1
return -1;
}
/**
* Returns true if the current day is Yom Tov. The method returns true even for holidays such as {@link #CHANUKAH} and minor
* ones such as {@link #TU_BEAV} and {@link #PESACH_SHENI}. Erev Yom Tov (with the exception of {@link #HOSHANA_RABBA},
* Erev the second days of Pesach) returns false, as do {@link #isTaanis() fast days} besides {@link #YOM_KIPPUR}. Use
* {@link #isAssurBemelacha()} to find the days that have a prohibition of work.
*
* @return true if the current day is a Yom Tov
*
* @see #getYomTovIndex()
* @see #isErevYomTov()
* @see #isErevYomTovSheni()
* @see #isTaanis()
* @see #isAssurBemelacha()
* @see #isCholHamoed()
*/
public isYomTov(): boolean {
const holidayIndex: number = this.getYomTovIndex();
if ((this.isErevYomTov() && (holidayIndex !== JewishCalendar.HOSHANA_RABBA
&& (holidayIndex === JewishCalendar.CHOL_HAMOED_PESACH && this.getJewishDayOfMonth() !== 20)))
|| (this.isTaanis() && holidayIndex !== JewishCalendar.YOM_KIPPUR)) {
return false;
}
return this.getYomTovIndex() !== -1;
}
/**
* Returns true if the <em>Yom Tov</em> day has a <em>melacha</em> (work) prohibition. This method will return false for a
* non-<em>Yom Tov</em> day, even if it is <em>Shabbos</em>.
*
* @return if the <em>Yom Tov</em> day has a <em>melacha</em> (work) prohibition.
*/
public isYomTovAssurBemelacha(): boolean {
const yamimTovimAssurBemelacha = [
JewishCalendar.PESACH,
JewishCalendar.SHAVUOS,
JewishCalendar.SUCCOS,
JewishCalendar.SHEMINI_ATZERES,
JewishCalendar.SIMCHAS_TORAH,
JewishCalendar.ROSH_HASHANA,
JewishCalendar.YOM_KIPPUR,
];
const holidayIndex: number = this.getYomTovIndex();
return yamimTovimAssurBemelacha.includes(holidayIndex);
}
/**
* Returns true if it is <em>Shabbos</em> or if it is a <em>Yom Tov</em> day that has a <em>melacha</em> (work) prohibition.
* This method will return false for a.
* @return if the day is a <em>Yom Tov</em> that is <em>assur bemlacha</em> or <em>Shabbos</em>
*/
public isAssurBemelacha(): boolean {
return this.getDayOfWeek() === SATURDAY || this.isYomTovAssurBemelacha();
}
/**
* Returns true if the day has candle lighting. This will return true on erev <em>Shabbos</em>, erev <em>Yom Tov</em>, the
* first day of <em>Rosh Hashana</em> and the first days of <em>Yom Tov</em> out of Israel. It is identical
* to calling {@link #isTomorrowShabbosOrYomTov()}.
*
* @return if the day has candle lighting
*/
public hasCandleLighting(): boolean {
return this.isTomorrowShabbosOrYomTov();
}
/**
* Returns true if tomorrow is <em>Shabbos</em> or <em>Yom Tov</em>. This will return true on erev <em>Shabbos</em>, erev
* <em>Yom Tov</em>, the first day of <em>Rosh Hashana</em> and <em>erev</em> the first days of <em>Yom Tov</em> out of
* Israel. It is identical to calling {@link #hasCandleLighting()}.
* @return will return if the next day is <em>Shabbos</em> or <em>Yom Tov</em>
*/
public isTomorrowShabbosOrYomTov(): boolean {
return this.getDayOfWeek() === FRIDAY || this.isErevYomTov() || this.isErevYomTovSheni();
}
/**
* Returns true if the day is the second day of <em>Yom Tov</em>. This impacts the second day of <em>Rosh Hashana</em>
* everywhere, and the second days of Yom Tov in <em>chutz laaretz</em> (out of Israel).
*
* @return if the day is the second day of <em>Yom Tov</em>.
*/
public isErevYomTovSheni(): boolean {
return (this.getJewishMonth() === JewishCalendar.TISHREI && (this.getJewishDayOfMonth() === 1))
|| (!this.getInIsrael()
&& ((this.getJewishMonth() === JewishCalendar.NISSAN && [15, 21].includes(this.getJewishDayOfMonth()))
|| (this.getJewishMonth() === JewishCalendar.TISHREI && [15, 22].includes(this.getJewishDayOfMonth()))
|| (this.getJewishMonth() === JewishCalendar.SIVAN && this.getJewishDayOfMonth() === 6)));
}
/**
* Returns true if the current day is <em>Aseret Yemei Teshuva</em>.
*
* @return if the current day is <em>Aseret Yemei Teshuvah</em>
*/
public isAseresYemeiTeshuva(): boolean {
return this.getJewishMonth() === JewishCalendar.TISHREI && this.getJewishDayOfMonth() <= 10;
}
/**
* Returns true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em> or <em>Succos</em>.
*
* @return true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em> or <em>Succos</em>
* @see #isYomTov()
* @see #CHOL_HAMOED_PESACH
* @see #CHOL_HAMOED_SUCCOS
*/
public isCholHamoed(): boolean {
return this.isCholHamoedPesach() || this.isCholHamoedSuccos();
}
/**
* Returns true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em>.
*
* @return true if the current day is <em>Chol Hamoed</em> of <em>Pesach</em>
* @see #isYomTov()
* @see #CHOL_HAMOED_PESACH
*/
public isCholHamoedPesach(): boolean {
const holidayIndex: number = this.getYomTovIndex();
return holidayIndex === JewishCalendar.CHOL_HAMOED_PESACH;
}
/**
* Returns true if the current day is <em>Chol Hamoed</em> of <em>Succos</em>.
*
* @return true if the current day is <em>Chol Hamoed</em> of <em>Succos</em>
* @see #isYomTov()
* @see #CHOL_HAMOED_SUCCOS
*/
public isCholHamoedSuccos(): boolean {
const holidayIndex: number = this.getYomTovIndex();
return holidayIndex === JewishCalendar.CHOL_HAMOED_SUCCOS;
}
/**
* Returns true if the current day is erev Yom Tov. The method returns true for Erev - Pesach (first and last days),
* Shavuos, Rosh Hashana, Yom Kippur and Succos and Hoshana Rabba.
*
* @return true if the current day is Erev - Pesach, Shavuos, Rosh Hashana, Yom Kippur and Succos
* @see #isYomTov()
* @see #isErevYomTovSheni()
*/
public isErevYomTov(): boolean {
const erevYomTov = [
JewishCalendar.EREV_PESACH,
JewishCalendar.EREV_SHAVUOS,
JewishCalendar.EREV_ROSH_HASHANA,
JewishCalendar.EREV_YOM_KIPPUR,
JewishCalendar.EREV_SUCCOS,
JewishCalendar.HOSHANA_RABBA,
];
const holidayIndex: number = this.getYomTovIndex();
return erevYomTov.includes(holidayIndex)
|| (holidayIndex === JewishCalendar.CHOL_HAMOED_PESACH && this.getJewishDayOfMonth() === 20);
}
/**
* Returns true if the current day is Erev Rosh Chodesh. Returns false for Erev Rosh Hashana
*
* @return true if the current day is Erev Rosh Chodesh. Returns false for Erev Rosh Hashana
* @see #isRoshChodesh()
*/
public isErevRoshChodesh(): boolean {
// Erev Rosh Hashana is not Erev Rosh Chodesh.
return (this.getJewishDayOfMonth() === 29 && this.getJewishMonth() !== JewishCalendar.ELUL);
}
/**
* Return true if the day is a Taanis (fast day). Return true for 17 of Tammuz, Tisha B'Av, Yom Kippur, Fast of
* Gedalyah, 10 of Teves and the Fast of Esther
*
* @return true if today is a fast day
*/
public isTaanis(): boolean {
const taaniyos = [
JewishCalendar.SEVENTEEN_OF_TAMMUZ,
JewishCalendar.TISHA_BEAV,
JewishCalendar.YOM_KIPPUR,
JewishCalendar.FAST_OF_GEDALYAH,
JewishCalendar.TENTH_OF_TEVES,
JewishCalendar.FAST_OF_ESTHER,
];
const holidayIndex: number = this.getYomTovIndex();
return taaniyos.includes(holidayIndex);
}
/**
* Return true if the day is Taanis Bechoros (on erev Pesach). It will return true for the 14th of Nissan if it is not
* on Shabbos, or if the 12th of Nissan occurs on a Thursday
*
* @return true if today is the fast of Bechoros
*/
public isTaanisBechoros(): boolean {
const day: number = this.getJewishDayOfMonth();
const dayOfWeek: number = this.getDayOfWeek();
// on 14 Nisan unless that is Shabbos where the fast is moved back to Thursday
return this.getJewishMonth() === JewishCalendar.NISSAN && ((day === 14 && dayOfWeek !== Calendar.SATURDAY)
|| (day === 12 && dayOfWeek === Calendar.THURSDAY));
}
/**
* Returns the day of <em>Chanukah</em> or -1 if it is not <em>Chanukah</em>.
*
* @return the day of <em>Chanukah</em> or -1 if it is not <em>Chanukah</em>.
* @see #isChanukah()
*/
public getDayOfChanukah(): number {
const day: number = this.getJewishDayOfMonth();
if (this.isChanukah()) {
if (this.getJewishMonth() === JewishCalendar.KISLEV) {
return day - 24;
}
// teves
return this.isKislevShort() ? day + 5 : day + 6;
}
return -1;
}
/**
* Returns true if the current day is one of the 8 days of <em>Chanukah</em>.
* @return if the current day is one of the 8 days of <em>Chanukah</em>.
* @see #getDayOfChanukah()
*/
public isChanukah(): boolean {
return this.getYomTovIndex() === JewishCalendar.CHANUKAH;
}
/**
* Returns if the day is Rosh Chodesh. Rosh Hashana will return false
*
* @return true if it is Rosh Chodesh. Rosh Hashana will return false
*/
public isRoshChodesh(): boolean {
// Rosh Hashana is not rosh chodesh. Elul never has 30 days
return (this.getJewishDayOfMonth() === 1 && this.getJewishMonth() !== JewishCalendar.TISHREI) || this.getJewishDayOfMonth() === 30;
}
/**
* Returns if the day is Shabbos and sunday is Rosh Chodesh.
*
* @return true if it is Shabbos and sunday is Rosh Chodesh.
*/
public isMacharChodesh(): boolean {
return (this.getDayOfWeek() === SATURDAY && (this.getJewishDayOfMonth() === 30 || this.getJewishDayOfMonth() === 29));
}
/**
* Returns if the day is Shabbos Mevorchim.
*
* @return true if it is Shabbos Mevorchim.
*/
public isShabbosMevorchim(): boolean {
return this.getDayOfWeek() === SATURDAY
&& this.getJewishDayOfMonth() >= 23
&& this.getJewishDayOfMonth() <= 29
&& this.getJewishMonth() !== JewishCalendar.ELUL;
}
/**