Skip to content

Commit

Permalink
fix date time parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnani committed Aug 27, 2021
1 parent f915e7a commit 550c011
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ func diffEvents(cfg Config, up []gocal.Event, gevent []*calendar.Event) ([]*cale
}
t, err := time.Parse(time.RFC3339, g.Start.DateTime)
if err != nil {
log.Fatalf("Unable to parse date time %s: %v", g.Start.DateTime, err)
log.Fatalf("Unable to parse start date time %s: %v", g.Start.DateTime, err)
}
if !t.Equal(*e.Start) {
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 date time %s: %v", g.End.DateTime, err)
log.Fatalf("Unable to parse end date time %s: %v", g.End.DateTime, err)
}
if !t.Equal(*e.End) {
n.End = &calendar.EventDateTime{DateTime: e.End.Format(time.RFC3339)}
Expand Down Expand Up @@ -129,9 +129,9 @@ func diffEvents(cfg Config, up []gocal.Event, gevent []*calendar.Event) ([]*cale
del := make([]string, 0, len(ids))
for _, e := range ids {
if e.Status != "cancelled" {
t, err := time.Parse(e.Start.DateTime, time.RFC3339)
t, err := time.Parse(time.RFC3339, e.Start.DateTime)
if err != nil {
log.Fatalf("Unable to parse date time %s: %v", e.Start.DateTime, err)
log.Fatalf("Unable to parse canceled date time %s: %v", e.Start.DateTime, err)
}
if time.Now().Before(t) {
del = append(del, e.Id)
Expand Down

0 comments on commit 550c011

Please sign in to comment.