fix:#31 switch time format in functions and calendar

This commit is contained in:
masterelmar
2023-10-28 14:48:25 +02:00
parent 7228d17d84
commit 4aed6b58ee
6 changed files with 66 additions and 58 deletions

View File

@@ -1,9 +1,11 @@
package ical
import (
"github.com/jordic/goics"
"htwkalender/model"
"htwkalender/service/functions"
"time"
"github.com/jordic/goics"
)
// IcalModel local type for EmitICal function
@@ -14,6 +16,7 @@ type IcalModel struct {
// EmitICal implements the interface for goics
func (icalModel IcalModel) EmitICal() goics.Componenter {
europeTime, _ := time.LoadLocation("Europe/Berlin")
c := goics.NewComponent()
c.SetType("VCALENDAR")
c.AddProperty("VERSION", "2.0")
@@ -25,9 +28,9 @@ func (icalModel IcalModel) EmitICal() goics.Componenter {
for _, event := range icalModel.Events {
s := goics.NewComponent()
s.SetType("VEVENT")
k, v := goics.FormatDateTime("DTEND;TZID=Europe/Berlin", event.End)
k, v := goics.FormatDateTime("DTEND;TZID=Europe/Berlin", event.End.Time().Local().In(europeTime))
s.AddProperty(k, v)
k, v = goics.FormatDateTime("DTSTART;TZID=Europe/Berlin", event.Start)
k, v = goics.FormatDateTime("DTSTART;TZID=Europe/Berlin", event.Start.Time().Local().In(europeTime))
s.AddProperty(k, v)
s.AddProperty("SUMMARY", replaceNameIfUserDefined(event.Name, icalModel.Mapping))
s.AddProperty("DESCRIPTION", generateDescription(event))