mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2025-10-29 09:15:33 +00:00
resetbutton & almanach edit start
This commit is contained in:
@@ -3,6 +3,8 @@ package functions
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/pocketbase/pocketbase/tools/types"
|
||||
)
|
||||
|
||||
type Weekday struct {
|
||||
@@ -18,6 +20,7 @@ type Month struct {
|
||||
}
|
||||
|
||||
var Months = []Month{
|
||||
{"N/A", "N/A", 0},
|
||||
{"Januar", "Jan", 1},
|
||||
{"Februar", "Feb", 2},
|
||||
{"März", "Mär", 3},
|
||||
@@ -30,7 +33,6 @@ var Months = []Month{
|
||||
{"Oktober", "Okt", 10},
|
||||
{"November", "Nov", 11},
|
||||
{"Dezember", "Dez", 12},
|
||||
{"N/A", "N/A", 0},
|
||||
}
|
||||
|
||||
var Weekdays = []Weekday{
|
||||
@@ -65,3 +67,27 @@ func GetMonth(month any) Month {
|
||||
fmt.Println("Invalid month value", month)
|
||||
return Months[12]
|
||||
}
|
||||
|
||||
func GermanDate(t types.DateTime) string {
|
||||
if t.IsZero() {
|
||||
return "N/A"
|
||||
}
|
||||
|
||||
location, _ := time.LoadLocation("Europe/Berlin")
|
||||
|
||||
time := t.Time().In(location)
|
||||
month := Months[time.Month()]
|
||||
weekday := Weekdays[time.Weekday()]
|
||||
return fmt.Sprintf("%s, %d. %s %d", weekday.ShortName, time.Day(), month.ShortName, time.Year())
|
||||
}
|
||||
|
||||
func GermanTime(t types.DateTime) string {
|
||||
if t.IsZero() {
|
||||
return "N/A"
|
||||
}
|
||||
|
||||
location, _ := time.LoadLocation("Europe/Berlin")
|
||||
|
||||
time := t.Time().In(location)
|
||||
return fmt.Sprintf("%02d:%02d", time.Hour(), time.Minute())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user