When inserting an event in google-calendar-api using Golang I can get my event to work when I hard code the date ‘DateTime: “2019-04-11T14:00:00”,’
but not when I generated it from variables ‘DateTime: evtEndDate + “T” + evtEndTime,’
I can’t see any difference but the API does
Here I printf the constructed variable and it’s type followed by the hardcoded variable and it’s type. They look identical
2019-04-11T06:00:00 string
2019-04-11T06:00:00 string
2019-04-11T14:00:00 string
2019-04-11T14:00:00 string
2019/04/11 12:48:17 Unable to create event. googleapi: Error 400: Invalid value for: Invalid format: "2019-04-11T14:00:00", invalid
exit status 1
part of the go code I’m using is:
event := &calendar.Event{
Summary: data.schShift + " - Test Event",
Location: "Canada",
Description: "Test event added by Go utility",
Start: &calendar.EventDateTime{
// This doesn't work
DateTime: evtStartDate + "T" + evtStartTime,
// This works (when unREM'd
// DateTime: "2019-04-11T06:00:00",
TimeZone: "America/Toronto",
},
End: &calendar.EventDateTime{
// This doesn't work
DateTime: evtEndDate + "T" + evtEndTime,
// This works (when unREM'd
// DateTime: "2019-04-11T14:00:00",
TimeZone: "America/Toronto",
},
}
evtStartDate = evtStartDate + "T" + evtStartTime
fmt.Printf("%v\t%T\n", evtStartDate, evtStartDate)
fmt.Printf("%v\t%T\n", event.Start.DateTime, event.Start.DateTime)
evtEndDate = evtEndDate + "T" + evtEndTime
fmt.Printf("%v\t%T\n", evtEndDate, evtEndDate)
fmt.Printf("%v\t%T\n", event.End.DateTime, event.End.DateTime)
I expected the variable to be accepted as it seems to be the same type but no