feat:#31 updated database start end to date

This commit is contained in:
masterelmar
2023-10-28 11:10:06 +02:00
parent d10343fe89
commit 7228d17d84
7 changed files with 667 additions and 33 deletions

View File

@@ -4,10 +4,9 @@ import (
"github.com/jordic/goics"
"htwkalender/model"
"htwkalender/service/functions"
"time"
)
// local type for EmitICal function
// IcalModel local type for EmitICal function
type IcalModel struct {
Events model.Events
Mapping []model.FeedCollection
@@ -15,7 +14,6 @@ type IcalModel struct {
// EmitICal implements the interface for goics
func (icalModel IcalModel) EmitICal() goics.Componenter {
layout := "2006-01-02 15:04:05 -0700 MST"
c := goics.NewComponent()
c.SetType("VCALENDAR")
c.AddProperty("VERSION", "2.0")
@@ -27,11 +25,9 @@ func (icalModel IcalModel) EmitICal() goics.Componenter {
for _, event := range icalModel.Events {
s := goics.NewComponent()
s.SetType("VEVENT")
timeEnd, _ := time.Parse(layout, event.End)
timeStart, _ := time.Parse(layout, event.Start)
k, v := goics.FormatDateTime("DTEND;TZID=Europe/Berlin", timeEnd)
k, v := goics.FormatDateTime("DTEND;TZID=Europe/Berlin", event.End)
s.AddProperty(k, v)
k, v = goics.FormatDateTime("DTSTART;TZID=Europe/Berlin", timeStart)
k, v = goics.FormatDateTime("DTSTART;TZID=Europe/Berlin", event.Start)
s.AddProperty(k, v)
s.AddProperty("SUMMARY", replaceNameIfUserDefined(event.Name, icalModel.Mapping))
s.AddProperty("DESCRIPTION", generateDescription(event))