From 4a0d3a850a5087f3101a0f43a71e06d48b12e1da Mon Sep 17 00:00:00 2001 From: tom Date: Sat, 22 Feb 2025 01:02:10 +0100 Subject: [PATCH] CHANGE: added timezone to db connection --- Backend/database.go | 2 +- Backend/models/booking.go | 2 +- Backend/templates/timeComponents.templ | 2 +- Backend/templates/timeComponents_templ.go | 4 ++-- Docker/.env.example | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Backend/database.go b/Backend/database.go index bf1c4de..1a6bf9e 100644 --- a/Backend/database.go +++ b/Backend/database.go @@ -13,7 +13,7 @@ func OpenDatabase() (*sql.DB, error) { dbUser := helper.GetEnv("POSTGRES_USER", "arbeit_zeit") dbPassword := helper.GetEnv("POSTGRES_PASS", "password") - connStr := fmt.Sprintf("postgres://%s:%s@%s:5432/%s?sslmode=disable", dbUser, dbPassword, dbHost, dbName) + connStr := fmt.Sprintf("postgres://%s:%s@%s:5432/%s?sslmode=disable&TimeZone=Europe/Berlin", dbUser, dbPassword, dbHost, dbName) return sql.Open("postgres", connStr) } diff --git a/Backend/models/booking.go b/Backend/models/booking.go index 4574e16..9290ae1 100644 --- a/Backend/models/booking.go +++ b/Backend/models/booking.go @@ -209,7 +209,7 @@ func checkLastBooking(b Booking) bool { func (b *Booking) UpdateTime(newTime time.Time){ hour, minute, _ := newTime.Clock() - if(hour == b.Timestamp.Local().Hour() && minute == b.Timestamp.Local().Minute()){ + if(hour == b.Timestamp.Hour() && minute == b.Timestamp.Minute()){ return } // TODO: add check for time overlap diff --git a/Backend/templates/timeComponents.templ b/Backend/templates/timeComponents.templ index 28ba16a..20e0175 100644 --- a/Backend/templates/timeComponents.templ +++ b/Backend/templates/timeComponents.templ @@ -122,7 +122,7 @@ templ lineComponent(){ templ bookingComponent(booking models.Booking) {

- {booking.Timestamp.Local().Format("15:04")} + {booking.Timestamp.Format("15:04")} {booking.GetBookingType()}

diff --git a/Backend/templates/timeComponents_templ.go b/Backend/templates/timeComponents_templ.go index f1b67db..7777352 100644 --- a/Backend/templates/timeComponents_templ.go +++ b/Backend/templates/timeComponents_templ.go @@ -430,9 +430,9 @@ func bookingComponent(booking models.Booking) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Local().Format("15:04")) + templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(booking.Timestamp.Format("15:04")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 125, Col: 103} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timeComponents.templ`, Line: 125, Col: 95} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) if templ_7745c5c3_Err != nil { diff --git a/Docker/.env.example b/Docker/.env.example index 5c4e89a..ae09d26 100644 --- a/Docker/.env.example +++ b/Docker/.env.example @@ -1,7 +1,7 @@ -POSTGRES_ADMIN=root -POSTGRES_ADMIN_PASS=very_secure -POSTGRES_USER=api_nuter -POSTGRES_PASSWORD=password +POSTGRES_USER=root +POSTGRES_PASSWORD=very_secure +POSTGRES_API_USER=api_nuter +POSTGRES_API_PASSWORD=password POSTGRES_PATH=../DB POSTGRES_DB=arbeitszeitmessung EXPOSED_PORT=8000