From 8c842b8cfa389f9fa14415ff9fa4e5143094e440 Mon Sep 17 00:00:00 2001 From: psic4t Date: Thu, 18 Apr 2024 09:42:58 +0200 Subject: [PATCH] fix SabreDAV/Nextcloud --- main.go | 4 +--- parse.go | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 0e18194..29e2d1c 100644 --- a/main.go +++ b/main.go @@ -202,7 +202,6 @@ func createAppointment(calNumber string, appointmentData string, recurrence stri var calSkel = `BEGIN:VCALENDAR VERSION:2.0 PRODID:-//qcal -METHOD:PUBLISH BEGIN:VTIMEZONE TZID:` + timezoneString + ` BEGIN:STANDARD @@ -220,7 +219,7 @@ END:DAYLIGHT END:VTIMEZONE BEGIN:VEVENT UID:` + curTime.UTC().Format(IcsFormat) + `-` + newElem + ` -DTSTART;` + dtStartString + ` +DTSTART;` + dtStartString + ` DTEND;` + dtEndString + ` DTSTAMP:` + curTime.UTC().Format(IcsFormat) + `Z SUMMARY:` + summary + calRec + ` @@ -240,7 +239,6 @@ END:VCALENDAR` log.Fatal(err) } fmt.Println(resp.Status) - } func main() { diff --git a/parse.go b/parse.go index cd3ddbc..5a46b6d 100644 --- a/parse.go +++ b/parse.go @@ -4,10 +4,11 @@ import ( //"encoding/json" "fmt" // "log" - duration "github.com/channelmeter/iso8601duration" "regexp" "strings" "time" + + duration "github.com/channelmeter/iso8601duration" ) var ( @@ -18,7 +19,7 @@ var ( eventFreqYearlyRegex = regexp.MustCompile(`RRULE:FREQ=YEARLY\n`) ) -// unixtimestamp +// unixtimestamp const ( uts = "1136239445" //ics date time format @@ -80,13 +81,15 @@ func parseTimeField(fieldName string, eventData string) (time.Time, string) { } else { // event that has start hour and minute result := re.FindStringSubmatch(eventData) + //fmt.Println(result) if result == nil || len(result) < 4 { return t, tzID } tzID = result[2] - dt := strings.Trim(result[4], "\r") // trim that newlines! + //fmt.Println(tzID) + dt := strings.Trim(result[4], "\r") // trim these newlines! if strings.HasSuffix(dt, "Z") { // If string ends in 'Z', timezone is UTC @@ -97,6 +100,7 @@ func parseTimeField(fieldName string, eventData string) (time.Time, string) { } else if tzID != "" { format = "20060102T150405" location, err := time.LoadLocation(tzID) + //fmt.Println(location) // if tzID not readable use configured timezone if err != nil { location, _ = time.LoadLocation(config.Timezone) -- 2.45.2