Skip to content

Commit

Permalink
Improved fault tolerance and diffing
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnani committed Jul 15, 2022
1 parent 53ccdd0 commit f36e1fa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func parseICal(url string) []gocal.Event {
body := bytes.NewReader(dateFormatFix.ReplaceAll(b, []byte("$1")))

c := gocal.NewParser(body)
c.Strict = gocal.StrictParams{
Mode: gocal.StrictModeFailAttribute,
}
if err := c.Parse(); err != nil {
panic(err)
}
Expand Down Expand Up @@ -101,15 +104,15 @@ func diffEvents(cfg Config, up []gocal.Event, gevent []*calendar.Event) ([]*cale
if err != nil {
log.Fatalf("Unable to parse start date time %s: %v", g.Start.DateTime, err)
}
if !t.Equal(*e.Start) {
if !t.Truncate(time.Second).Equal((*e.Start).Truncate(time.Second)) {
n.Start = &calendar.EventDateTime{DateTime: e.Start.Format(time.RFC3339)}
changed = true
}
t, err = time.Parse(time.RFC3339, g.End.DateTime)
if err != nil {
log.Fatalf("Unable to parse end date time %s: %v", g.End.DateTime, err)
}
if !t.Equal(*e.End) {
if !t.Truncate(time.Second).Equal((*e.End).Truncate(time.Second)) {
n.End = &calendar.EventDateTime{DateTime: e.End.Format(time.RFC3339)}
changed = true
}
Expand Down

0 comments on commit f36e1fa

Please sign in to comment.