From 3f98a5d5d69ac0fa9cded18b8aabb0cb08847d77 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 28 Jan 2024 05:03:35 -0600 Subject: [PATCH] Add NewCalendar helper, make timezone string constant, add version constant --- helpers.go | 11 +++++++++++ main.go | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/helpers.go b/helpers.go index a5de839..2800877 100644 --- a/helpers.go +++ b/helpers.go @@ -12,6 +12,7 @@ import ( "strings" "time" + ics "github.com/arran4/golang-ical" "github.com/bwmarrin/discordgo" "github.com/rs/zerolog" log "github.com/rs/zerolog/log" @@ -327,3 +328,13 @@ func GetFooter(time time.Time) *discordgo.MessageEmbedFooter { Text: fmt.Sprintf("Fetched at %s", time.Format("Monday, January 2, 2006 at 3:04:05PM")), } } + +func NewCalendar() *ics.Calendar { + c := &ics.Calendar{ + Components: []ics.Component{}, + CalendarProperties: []ics.CalendarProperty{}, + } + c.SetVersion(Version) + c.SetProductId("-//xevion//Banner Discord Bot//EN") + return c +} diff --git a/main.go b/main.go index 583510c..a3ab1c2 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,9 @@ var ( centralTime *time.Location ) +const Version = "0.0.1" +const CentralTimezone = "America/Chicago" + func init() { // Load environment variables if err := godotenv.Load(); err != nil { @@ -40,7 +43,7 @@ func init() { ctx = context.Background() var err error - centralTime, err = time.LoadLocation("America/Chicago") + centralTime, err = time.LoadLocation(CentralTimezone) if err != nil { panic(err) }