Skip to content

Commit

Permalink
Really fix invalid Zmanim by not adding to returned events list
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Dec 11, 2023
1 parent 9473e15 commit bf8a21d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hebcal/candles.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,11 @@ func dailyZemanim(date hdate.HDate, opts *CalOptions) []event.CalEvent {
{"Dusk", z.Dusk()},
{"Tzeit HaKochavim", z.Tzeit(zmanim.Tzeit3SmallStars)},
}
events := make([]event.CalEvent, len(times))
for i, ev := range times {
if !ev.t.IsZero() {
events[i] = NewTimedEvent(date, ev.desc, event.ZMANIM, ev.t, 0, nil, opts)
events := make([]event.CalEvent, 0, len(times))
for _, zman := range times {
if !zman.t.IsZero() {
ev := NewTimedEvent(date, zman.desc, event.ZMANIM, zman.t, 0, nil, opts)
events = append(events, ev)
}
}
return events
Expand Down
14 changes: 14 additions & 0 deletions hebcal/hebcal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,3 +546,17 @@ func TestYear1(t *testing.T) {
assert.Equal(t, nil, err)
assert.Equal(t, 79, len(events))
}

func TestHebrewCalendarZmanimOnly(t *testing.T) {
assert := assert.New(t)
loc := zmanim.LookupCity("Amsterdam")
opts := hebcal.CalOptions{
Start: hdate.New(5783, hdate.Sivan, 9),
End: hdate.New(5783, hdate.Sivan, 9),
Location: loc,
DailyZmanim: true,
}
events, err := hebcal.HebrewCalendar(&opts)
assert.Equal(nil, err)
assert.Equal(15, len(events)) // not 16 (no Alot HaShachar)
}

0 comments on commit bf8a21d

Please sign in to comment.