Skip to content

Commit 54a26a6

Browse files
committed
Add :year and :traditional-year to :hebrew.
1 parent 15170f7 commit 54a26a6

4 files changed

Lines changed: 40 additions & 11 deletions

File tree

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,19 @@ to calculate the day.
8282
;; =>
8383
{:hebrew
8484
{:days-in-month 30,
85-
:day-of-week 3,
85+
:traditional-year 5781,
86+
:day-of-week 5,
8687
:month-of-year 5,
8788
:minor-feast-day false,
88-
:day-of-month 9,
89+
:day-of-month 18,
90+
:year 6021,
8991
:major-feast-day false,
9092
:sabbath false,
9193
:names
9294
{:month-of-year "5th",
9395
:traditional-month-of-year "Av",
94-
:day-of-month "9th",
95-
:day-of-week "3rd day of the week"},
96+
:day-of-month "18th",
97+
:day-of-week "5th day of the week"},
9698
:months-in-year 12},
9799
:time
98100
{:year
@@ -106,13 +108,13 @@ to calculate the day.
106108
:start-adjusted-for-polar-region false,
107109
:end-adjusted-for-polar-region false},
108110
:week
109-
{:start #time/zoned-date-time "2021-08-14T19:23+03:00[Asia/Jerusalem]",
110-
:end #time/zoned-date-time "2021-08-21T19:15:59+03:00[Asia/Jerusalem]",
111+
{:start #time/zoned-date-time "2021-08-21T19:16+03:00[Asia/Jerusalem]",
112+
:end #time/zoned-date-time "2021-08-28T19:07:59+03:00[Asia/Jerusalem]",
111113
:start-adjusted-for-polar-region false,
112114
:end-adjusted-for-polar-region false},
113115
:day
114-
{:start #time/zoned-date-time "2021-08-16T19:21+03:00[Asia/Jerusalem]",
115-
:end #time/zoned-date-time "2021-08-17T19:19:59+03:00[Asia/Jerusalem]",
116+
{:start #time/zoned-date-time "2021-08-25T19:11+03:00[Asia/Jerusalem]",
117+
:end #time/zoned-date-time "2021-08-26T19:09:59+03:00[Asia/Jerusalem]",
116118
:start-adjusted-for-polar-region false,
117119
:end-adjusted-for-polar-region false}}}
118120
```
@@ -124,10 +126,12 @@ It too can be provided with a range of arguments which it passes on to `date`.
124126
;; =>
125127
{:hebrew
126128
{:days-in-month 30,
129+
:traditional-year 5781,
127130
:day-of-week 5,
128131
:month-of-year 5,
129132
:minor-feast-day false,
130133
:day-of-month 11,
134+
:year 6021,
131135
:major-feast-day false,
132136
:sabbath false,
133137
:names
@@ -167,10 +171,12 @@ to find a `date` in.
167171
;; =>
168172
{:hebrew
169173
{:days-in-month 30,
174+
:traditional-year 5785,
170175
:day-of-week 7,
171176
:month-of-year 1,
172177
:minor-feast-day false,
173178
:day-of-month 14,
179+
:year 6025,
174180
:major-feast-day
175181
{:name "Passover", :hebrew-name "Pesach", :day-of-feast 1, :days-in-feast 1},
176182
:sabbath true,

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject xyz.thoren/luminary "0.6.6-SNAPSHOT"
1+
(defproject xyz.thoren/luminary "0.7.0-SNAPSHOT"
22
:description "Calculate dates based on the Bible and the 1st Book of Enoch."
33
:url "https://github.com/johanthoren/luminary"
44
:license {:name "LGPL-3.0"

src/xyz/thoren/luminary.clj

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,18 @@
489489
(first)
490490
(inc))))
491491

492+
(defn- hebrew-year
493+
[start-of-year]
494+
(let [y (tick/int (tick/year start-of-year))]
495+
(+ 4000 y)))
496+
497+
(defn- trad-jewish-year
498+
[month-of-year start-of-year]
499+
(let [y (tick/int (tick/year start-of-year))]
500+
(if (> month-of-year 6)
501+
(+ 3761 y)
502+
(+ 3760 y))))
503+
492504
(def trad-month-names
493505
["Nisan" "Iyar" "Sivan" "Tammuz" "Av" "Elul" "Tishrei" "Marcheshvan" "Kislev"
494506
"Tevet" "Shevat" "Adar" "Adar II"])
@@ -666,11 +678,14 @@
666678
(defn- hebrew-date
667679
[lat lon y m t]
668680
(let [months-in-y (hebrew-months-in-year lat lon t)
681+
start-of-year (first y)
669682
moy (hebrew-month-of-year lat lon t)
670683
dom (hebrew-day-of-month lat lon t)
671684
dow (hebrew-day-of-week lat lon t)
672-
major-feast-day (major-feast-day moy dom dow (first y) (first m))]
673-
{:month-of-year moy
685+
major-feast-day (major-feast-day moy dom dow start-of-year (first m))]
686+
{:year (hebrew-year start-of-year)
687+
:traditional-year (trad-jewish-year moy start-of-year)
688+
:month-of-year moy
674689
:months-in-year months-in-y
675690
:day-of-month dom
676691
:days-in-month (hebrew-days-in-month lat lon t)

test/xyz/thoren/luminary_test.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,15 @@
586586
(l/date tm-lat tm-lon
587587
(apply l/zdt (flatten ["Asia/Jerusalem" args]))))]
588588
(let [h (r 2021 4 12 12 0)]
589+
(is (= 6020 (get-in h [:hebrew :year])))
590+
(is (= 5781 (get-in h [:hebrew :traditional-year])))
589591
(is (= 13 (get-in h [:hebrew :month-of-year])))
590592
(is (= 30 (get-in h [:hebrew :day-of-month])))
591593
(is (= 2 (get-in h [:hebrew :day-of-week])))
592594
(is (false? (get-in h [:hebrew :sabbath]))))
593595
(let [h (r 2021 4 12 23 0)]
596+
(is (= 6021 (get-in h [:hebrew :year])))
597+
(is (= 5781 (get-in h [:hebrew :traditional-year])))
594598
(is (= 1 (get-in h [:hebrew :month-of-year])))
595599
(is (= 1 (get-in h [:hebrew :day-of-month])))
596600
(is (= "Rosh Chodesh Nisan" (get-in h [:hebrew :minor-feast-day :hebrew-name])))
@@ -619,6 +623,8 @@
619623
(is (= "Feast of Weeks" (get-in h [:hebrew :major-feast-day :name])))
620624
(is (= "Sivan" (get-in h [:hebrew :names :traditional-month-of-year]))))
621625
(let [h (r 2021 10 6 23 0)]
626+
(is (= 6021 (get-in h [:hebrew :year])))
627+
(is (= 5782 (get-in h [:hebrew :traditional-year])))
622628
(is (= 7 (get-in h [:hebrew :month-of-year])))
623629
(is (= 1 (get-in h [:hebrew :day-of-month])))
624630
(is (= 5 (get-in h [:hebrew :day-of-week])))
@@ -675,6 +681,8 @@
675681
(is (= "Shushan Purim" (get-in h [:hebrew :major-feast-day :name])))
676682
(is (= "Adar I" (get-in h [:hebrew :names :traditional-month-of-year]))))
677683
(let [h (r 2021 3 26 23 0)]
684+
(is (= 6020 (get-in h [:hebrew :year])))
685+
(is (= 5781 (get-in h [:hebrew :traditional-year])))
678686
(is (= 13 (get-in h [:hebrew :month-of-year])))
679687
(is (= 14 (get-in h [:hebrew :day-of-month])))
680688
(is (= 7 (get-in h [:hebrew :day-of-week])))

0 commit comments

Comments
 (0)