Commit 1bdb2827 authored by Linus's avatar Linus 🤔
Browse files

Change time zone to Europe/Berlin

parent b17378b7
Pipeline #77746 passed with stages
in 25 seconds
......@@ -6,6 +6,7 @@ import (
"log"
"net/http"
"strconv"
"time"
)
var listingsFile string
......@@ -20,6 +21,14 @@ func hasSubject(subject string) bool {
return false
}
func getTime() string {
loc, err := time.LoadLocation("Europe/Berlin")
if err != nil {
panic(err)
}
return time.Now().In(loc).Format("02.01.2006 um 15:04")
}
func main() {
const DefaultPort = 8080
portPtr := flag.String("port", strconv.Itoa(DefaultPort),
......
......@@ -5,7 +5,6 @@ import (
"net/http"
"strconv"
"strings"
"time"
)
func search(w http.ResponseWriter, r *http.Request) error {
......@@ -91,7 +90,7 @@ func addListing(w http.ResponseWriter, r *http.Request) error {
if !hasSubject(strings.Split(subject, "::")[0]) {
return renderError("Das angegebene Fach existiert nicht", w, r)
}
listing := Listing{email, numStudents, message, time.Now().Format("02.01.2006 um 15:04")}
listing := Listing{email, numStudents, message, getTime()}
listingsMutex.Lock()
defer listingsMutex.Unlock()
listings[subject] = append(listings[subject], listing)
......
......@@ -3,7 +3,6 @@ package main
import (
"html/template"
"net/http"
"time"
)
func tutSwap(w http.ResponseWriter, r *http.Request) error {
......@@ -75,7 +74,7 @@ func addSwap(w http.ResponseWriter, r *http.Request) error {
if !hasSubject(subject) {
return renderError("Das angegebene Fach existiert nicht", w, r)
}
swap := TutSwap{email, from, to, message, time.Now().Format("02.01.2006 um 15:04")}
swap := TutSwap{email, from, to, message, getTime()}
swapMutex.Lock()
defer swapMutex.Unlock()
swaps[subject] = append(swaps[subject], swap)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment