Skip to content

Commit

Permalink
don't support full day events
Browse files Browse the repository at this point in the history
  • Loading branch information
shadyabhi committed Sep 29, 2024
1 parent 039c7f1 commit e72cbe5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion calendar/maccalendar/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package maccalendar
import (
"bufio"
"calsync/calendar"
"errors"
"fmt"
"log"
"os/exec"
"strings"
"time"
)

var ErrFullDayEvent = fmt.Errorf("full day event")

const (
timeLayout = "Jan 2, 2006 15:04 -0700"
iCalBulletPoint = "→"
Expand All @@ -32,6 +35,11 @@ func getEvents(iCalBuddyBinary string, calName string, nDays int) ([]calendar.Ev
}

event, err := getEvent(multilineEvent)
if errors.Is(err, ErrFullDayEvent) {
log.Printf("Skipped due to full day event")
continue
}

if err != nil {
return nil, fmt.Errorf("parsing event %s, got error %w", multilineEvent, err)
}
Expand Down Expand Up @@ -104,7 +112,7 @@ func getEvent(raw string) (calendar.Event, error) {
atLocation := strings.Index(timeLine, " at ")
if atLocation == -1 {
log.Printf("Event: '%s' doesn't have time associated to it, skipping for now", raw)
return event, nil
return event, ErrFullDayEvent
}

startDate := timeLine[:atLocation] + " "
Expand Down

0 comments on commit e72cbe5

Please sign in to comment.