Skip to content

Commit 79afe8c

Browse files
committed
One last fix
Signed-off-by: xplshn <[email protected]>
1 parent 187c772 commit 79afe8c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

britto.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func parseDate(dateStr string, now time.Time) (time.Time, int, error) {
160160
var year int
161161

162162
if len(dateStr) == 5 {
163-
// Parse date without year (DD/YY)
163+
// Parse date without year (DD/MM)
164164
date, err = time.Parse("02/01", dateStr)
165165
if err == nil {
166166
year = now.Year()
@@ -186,6 +186,9 @@ func parseDate(dateStr string, now time.Time) (time.Time, int, error) {
186186
}
187187

188188
func processReminders(reminders []Reminder, now time.Time, isBirthday bool, defaultRange int, templateCfg TemplateConfig) {
189+
// Truncate the current time to midnight (00:00:00)
190+
now = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
191+
189192
for _, reminder := range reminders {
190193
date, year, err := parseDate(reminder.Date, now)
191194
if err != nil {
@@ -224,8 +227,10 @@ func processReminders(reminders []Reminder, now time.Time, isBirthday bool, defa
224227
}
225228

226229
for _, yearsAhead := range []int{0, 1} {
230+
// Truncate nextDate to midnight to avoid time component issues
227231
nextDate := time.Date(now.Year()+yearsAhead, date.Month(), date.Day(), 0, 0, 0, 0, now.Location())
228232

233+
// Calculate days between now and nextDate
229234
daysUntilDate := int(nextDate.Sub(now).Hours() / 24)
230235
if daysUntilDate <= rangeDays && daysUntilDate >= 0 {
231236
printReminder(daysUntilDate, nextDate, year)

0 commit comments

Comments
 (0)