Skip to content

Commit

Permalink
Change Chanukah candle-lighting time from dusk to bein hashmashos,
Browse files Browse the repository at this point in the history
courtesy @MaxBGreenberg. bein hashmashos is 13.5 minutes before
solar depression of 7.083 degrees (#10)
  • Loading branch information
mjradwin committed Jan 30, 2024
1 parent 50cb48d commit e5c3279
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 33 deletions.
8 changes: 4 additions & 4 deletions hebcal/candles.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type TimedEvent struct {

func NewTimedEvent(hd hdate.HDate, desc string, flags event.HolidayFlags, t time.Time,
sunsetOffset int, linkedEvent event.CalEvent, opts *CalOptions) TimedEvent {
if (t == time.Time{}) {
if t.IsZero() {
return TimedEvent{}
}
var emoji string
Expand Down Expand Up @@ -136,7 +136,7 @@ func makeCandleEvent(hd hdate.HDate, opts *CalOptions, ev event.CalEvent) TimedE
} else {
eventTime = z.Tzeit(opts.HavdalahDeg)
}
if (eventTime == time.Time{}) {
if eventTime.IsZero() {
return TimedEvent{} // no sunset
}
desc := "Candle lighting"
Expand All @@ -162,8 +162,8 @@ func makeChanukahCandleLighting(ev event.HolidayEvent, opts *CalOptions) TimedEv
year, month, day := hd.Greg()
gregDate := time.Date(year, month, day, 0, 0, 0, 0, time.UTC)
z := zmanim.New(loc, gregDate)
candleLightingTime := z.Dusk()
if (candleLightingTime == time.Time{}) {
candleLightingTime := z.BeinHashmashos()
if candleLightingTime.IsZero() {
return TimedEvent{} // no sunset
}
return TimedEvent{
Expand Down
14 changes: 7 additions & 7 deletions hebcal/hebcal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ func TestHebrewCalendarChanukahCandles(t *testing.T) {
assert.Equal(nil, err)
assert.Equal(14, len(events))
expected := []string{
"2022-12-18 Chanukah: 1 Candle: 5:04",
"2022-12-19 Chanukah: 2 Candles: 5:05",
"2022-12-20 Chanukah: 3 Candles: 5:05",
"2022-12-21 Chanukah: 4 Candles: 5:06",
"2022-12-22 Chanukah: 5 Candles: 5:06",
"2022-12-18 Chanukah: 1 Candle: 4:56",
"2022-12-19 Chanukah: 2 Candles: 4:57",
"2022-12-20 Chanukah: 3 Candles: 4:57",
"2022-12-21 Chanukah: 4 Candles: 4:58",
"2022-12-22 Chanukah: 5 Candles: 4:58",
"2022-12-23 Chanukah: 6 Candles: 4:00",
"2022-12-23 Candle lighting: 4:00",
"2022-12-24 Chag HaBanot",
"2022-12-24 Chanukah: 7 Candles: 5:20",
"2022-12-24 Rosh Chodesh Tevet",
"2022-12-24 Havdalah: 5:20",
"2022-12-25 Chanukah: 8 Candles: 5:08",
"2022-12-25 Chanukah: 8 Candles: 5:00",
"2022-12-25 Rosh Chodesh Tevet",
"2022-12-26 Chanukah: 8th Day",
}
Expand Down Expand Up @@ -557,5 +557,5 @@ func TestHebrewCalendarZmanimOnly(t *testing.T) {
}
events, err := hebcal.HebrewCalendar(&opts)
assert.Equal(nil, err)
assert.Equal(15, len(events)) // not 16 (no Alot HaShachar)
assert.Equal(14, len(events)) // not 15 (no Alot HaShachar)
}
15 changes: 9 additions & 6 deletions zmanim/zmanim.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ func New(location *Location, date time.Time) Zmanim {
return Zmanim{Location: location, Year: year, Month: month, Day: day, loc: loc}
}

var nilTime = time.Time{}

func (z *Zmanim) inLoc(dt time.Time) time.Time {
if dt == nilTime {
if dt.IsZero() {
return dt
}
return dt.In(z.loc)
Expand Down Expand Up @@ -229,15 +227,20 @@ func (z *Zmanim) Tzeit(angle float64) time.Time {
return z.timeAtAngle(angle, false)
}

const ThirteenFive time.Duration = -1 * time.Duration(13.5*float64(time.Minute))

// Rabbeinu Tam holds that bein hashmashos is a specific time between sunset and tzeis hakochavim
// One opinion on how to calculate this time is that it is 13.5 minutes before tzies 7.083
func (z *Zmanim) BeinHashmashos() time.Time {
tzeis:=z.Tzeit(Tzeit3MediumStars)
return tzeis.Add(-time.Duration(13.5 * float64(time.Minute)))
tzeis := z.Tzeit(Tzeit3MediumStars)
if tzeis.IsZero() {
return tzeis
}
return tzeis.Add(ThirteenFive)
}

func (z *Zmanim) riseSetOffset(t time.Time, offset int, roundTime bool) time.Time {
if t == nilTime {
if t.IsZero() {
return t
}
year, month, day := t.Date()
Expand Down
23 changes: 7 additions & 16 deletions zmanim/zmanim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func TestZmanimChicago(t *testing.T) {
"Fri, 05 Jun 2020 03:25:34 -0500",
"Fri, 05 Jun 2020 04:03:11 -0500",
"Fri, 05 Jun 2020 04:12:55 -0500",
"Fri, 05 Jun 2020 04:42:37 -0500",
"Fri, 05 Jun 2020 05:16:28 -0500",
"Fri, 05 Jun 2020 09:02:54 -0500",
"Fri, 05 Jun 2020 08:26:54 -0500",
Expand All @@ -31,7 +30,8 @@ func TestZmanimChicago(t *testing.T) {
"Fri, 05 Jun 2020 17:13:32 -0500",
"Fri, 05 Jun 2020 18:47:53 -0500",
"Fri, 05 Jun 2020 20:22:15 -0500",
"Fri, 05 Jun 2020 20:56:06 -0500",
"Fri, 05 Jun 2020 20:50:02 -0500",
"Fri, 05 Jun 2020 21:03:32 -0500",
"Fri, 05 Jun 2020 21:13:28 -0500",
}
times := []time.Time{
Expand All @@ -51,6 +51,7 @@ func TestZmanimChicago(t *testing.T) {
zman.PlagHaMincha(),
zman.Sunset(),
zman.BeinHashmashos(),
zman.Tzeit(7.083),
zman.Tzeit(8.5),
}
actual := make([]string, 18)
Expand All @@ -74,7 +75,6 @@ func TestZmanimTelAviv(t *testing.T) {
"Sat, 06 Mar 2021 04:50:19 +0200",
"Sat, 06 Mar 2021 05:12:02 +0200",
"Sat, 06 Mar 2021 05:18:11 +0200",
"Sat, 06 Mar 2021 05:38:01 +0200",
"Sat, 06 Mar 2021 06:02:30 +0200",
"Sat, 06 Mar 2021 08:57:23 +0200",
"Sat, 06 Mar 2021 08:21:23 +0200",
Expand All @@ -85,7 +85,8 @@ func TestZmanimTelAviv(t *testing.T) {
"Sat, 06 Mar 2021 15:16:20 +0200",
"Sat, 06 Mar 2021 16:29:12 +0200",
"Sat, 06 Mar 2021 17:42:05 +0200",
"Sat, 06 Mar 2021 18:06:34 +0200",
"Sat, 06 Mar 2021 17:58:11 +0200",
"Sat, 06 Mar 2021 18:11:41 +0200",
"Sat, 06 Mar 2021 18:18:23 +0200",
}
times := []time.Time{
Expand All @@ -94,7 +95,6 @@ func TestZmanimTelAviv(t *testing.T) {
zman.AlotHaShachar(),
zman.Misheyakir(),
zman.MisheyakirMachmir(),
zman.Dawn(),
zman.Sunrise(),
zman.SofZmanShma(),
zman.SofZmanShmaMGA(),
Expand All @@ -105,8 +105,8 @@ func TestZmanimTelAviv(t *testing.T) {
zman.MinchaKetana(),
zman.PlagHaMincha(),
zman.Sunset(),
zman.Dusk(),
zman.BeinHashmashos(),
zman.Tzeit(7.083),
zman.Tzeit(8.5),
}
actual := make([]string, 18)
Expand Down Expand Up @@ -145,7 +145,7 @@ func TestZmanimHelsinki(t *testing.T) {
} else {
t = zman.Tzeit(8.5)
}
if (t == time.Time{}) {
if t.IsZero() {
actual[idx] = "undefined"
} else {
actual[idx] = t.Format(time.RFC1123Z)
Expand Down Expand Up @@ -177,15 +177,6 @@ func ExampleZmanim_SunsetOffset() {
// 2020-06-05 21:12:00 -0500 CDT
}

func ExampleZmanim_Dusk() {
dt := time.Date(2022, time.December, 24, 12, 0, 0, 0, time.UTC)
location := zmanim.NewLocation("Amund Ringnes Island", "CA", 78.305499, -96.917471, "America/Regina")
zman := zmanim.New(&location, dt)
dusk := zman.Dusk()
fmt.Println(dusk)
// Output: 0001-01-01 00:00:00 +0000 UTC
}

func TestZmanimAmsterdam(t *testing.T) {
assert := assert.New(t)
dt := time.Date(2023, time.May, 29, 12, 0, 0, 0, time.UTC)
Expand Down

0 comments on commit e5c3279

Please sign in to comment.