From 848f4bf7bd1b7eda622fe16688609b8c5913f48b Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Wed, 27 Mar 2024 23:08:40 +0000 Subject: [PATCH] Add dayString calculation for CIF updates --- src/cif/helpers.go | 22 ++++++++++++++++++++++ src/main.go | 1 + 2 files changed, 23 insertions(+) create mode 100644 src/cif/helpers.go diff --git a/src/cif/helpers.go b/src/cif/helpers.go new file mode 100644 index 0000000..af2cc4a --- /dev/null +++ b/src/cif/helpers.go @@ -0,0 +1,22 @@ +package cif + +import ( + "time" + + "git.fjla.uk/owlboard/timetable-mgr/log" + "go.uber.org/zap" +) + +func getDayString() string { + london, err := time.LoadLocation("Europe/London") + if err != nil { + log.Msg.Error("Unable to load time zone info", zap.Error(err)) + } + + timeNow := time.Now().In(london) + day := timeNow.Weekday() + + dayStrings := [...]string{"sun", "mon", "tue", "wed", "thu", "fri", "sat"} + + return dayStrings[day] +} diff --git a/src/main.go b/src/main.go index 3319e1d..d2e37a2 100644 --- a/src/main.go +++ b/src/main.go @@ -6,6 +6,7 @@ import ( "os/signal" "syscall" "time" + _ "time/tzdata" "git.fjla.uk/owlboard/timetable-mgr/background" "git.fjla.uk/owlboard/timetable-mgr/dbAccess"