fixed #60
This commit is contained in:
@@ -68,3 +68,10 @@ func GetWorkingDays(startDate, endDate time.Time) int {
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func FormatGermanDayOfWeek(t time.Time) string {
|
||||
return days[t.Weekday()][:2]
|
||||
}
|
||||
|
||||
var days = [...]string{
|
||||
"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"}
|
||||
|
||||
@@ -18,7 +18,7 @@ func TestGetMonday(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFormatDuration(t *testing.T) {
|
||||
durations := []struct {
|
||||
testCases := []struct {
|
||||
name string
|
||||
duration time.Duration
|
||||
}{
|
||||
@@ -28,9 +28,9 @@ func TestFormatDuration(t *testing.T) {
|
||||
{"-1h 30min", time.Duration(-90 * time.Minute)},
|
||||
{"", 0},
|
||||
}
|
||||
for _, d := range durations {
|
||||
t.Run(d.name, func(t *testing.T) {
|
||||
if FormatDuration(d.duration) != d.name {
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if FormatDuration(tc.duration) != tc.name {
|
||||
t.Error("Format missmatch in Formatduration.")
|
||||
}
|
||||
})
|
||||
@@ -58,3 +58,27 @@ func TestGetWorkingDays(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestFormatGermanDayOfWeek(t *testing.T) {
|
||||
testCases := []struct {
|
||||
date string
|
||||
result string
|
||||
}{
|
||||
{"2025-12-01", "Mo"},
|
||||
{"2025-12-02", "Di"},
|
||||
{"2025-12-03", "Mi"},
|
||||
{"2025-12-04", "Do"},
|
||||
{"2025-12-05", "Fr"},
|
||||
{"2025-12-06", "Sa"},
|
||||
{"2025-12-07", "So"},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(fmt.Sprintf("FormatWeekDayTest: %s date", tc.date), func(t *testing.T) {
|
||||
date, _ := time.Parse(time.DateOnly, tc.date)
|
||||
if FormatGermanDayOfWeek(date) != tc.result {
|
||||
t.Error("Formatted workday did not match!")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ templ defaultWeekDayComponent(u models.User, day models.IWorkDay) {
|
||||
<div class="flex flex-row gap-2">
|
||||
@timeGaugeComponent(day.GetDayProgress(u), false)
|
||||
<div class="flex flex-col">
|
||||
<p class=""><span class="font-bold uppercase hidden md:inline">{ day.Date().Format("Mon") }:</span> { day.Date().Format("02.01.2006") }</p>
|
||||
<p class=""><span class="font-bold uppercase hidden md:inline">{ helper.FormatGermanDayOfWeek(day.Date()) }:</span> { day.Date().Format("02.01.2006") }</p>
|
||||
if day.IsWorkDay() {
|
||||
{{
|
||||
workDay, _ := day.(*models.WorkDay)
|
||||
|
||||
@@ -151,9 +151,9 @@ func defaultWeekDayComponent(u models.User, day models.IWorkDay) templ.Component
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("Mon"))
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatGermanDayOfWeek(day.Date()))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 35, Col: 92}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 35, Col: 108}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -166,7 +166,7 @@ func defaultWeekDayComponent(u models.User, day models.IWorkDay) templ.Component
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("02.01.2006"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 35, Col: 136}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/teamComponents.templ`, Line: 35, Col: 152}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
@@ -98,7 +98,7 @@ templ defaultDayComponent(day models.IWorkDay) {
|
||||
@timeGaugeComponent(day.GetDayProgress(user), day.Date().Equal(time.Now().Truncate(24*time.Hour)))
|
||||
<div>
|
||||
<p>
|
||||
<span class="font-bold uppercase hidden md:inline">{ day.Date().Format("Mon") }:</span> { day.Date().Format("02.01.2006") }
|
||||
<span class="font-bold uppercase hidden md:inline">{ helper.FormatGermanDayOfWeek(day.Date()) }:</span> { day.Date().Format("02.01.2006") }
|
||||
</p>
|
||||
if day.IsWorkDay() {
|
||||
{{
|
||||
|
||||
@@ -269,9 +269,9 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("Mon"))
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(helper.FormatGermanDayOfWeek(day.Date()))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 101, Col: 82}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 101, Col: 98}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
@@ -284,7 +284,7 @@ func defaultDayComponent(day models.IWorkDay) templ.Component {
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(day.Date().Format("02.01.2006"))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 101, Col: 126}
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/timePage.templ`, Line: 101, Col: 142}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
|
||||
Reference in New Issue
Block a user