add date parsing

This commit is contained in:
2025-12-15 09:48:39 +00:00
parent 16ec9a6e7c
commit f38c1715fc
4 changed files with 84 additions and 28 deletions

View File

@@ -6,14 +6,14 @@ import (
"github.com/b2dennis/meshi/xlsx"
)
var weekdays = [7]string{
var weekdays = []string{
"Sonntag",
"Montag",
"Dienstag",
"Mittwoch",
"Donnerstag",
"Freitag",
"Samstag",
"Sonntag",
}
templ Home(plan xlsx.Plan) {
@@ -31,7 +31,7 @@ templ Home(plan xlsx.Plan) {
@table.Header() {
@table.Row() {
@table.Head() {
Wochentag
Tag
}
@table.Head() {
Frühstück
@@ -44,7 +44,7 @@ templ Home(plan xlsx.Plan) {
}
}
}
for i,day := range(weekdays) {
for i := 0; i <= 6; i++ {
{{
class := ""
if i == 6 {
@@ -53,11 +53,11 @@ templ Home(plan xlsx.Plan) {
}}
@table.Row(table.RowProps{Class: class}) {
@table.Cell() {
{day}
{weekdays[plan[i][0].Date.Weekday()]}, {plan[i][0].Date.Format("02.01.2006")}
}
for _, menu := range plan.Menus[i] {
for _, menu := range plan[i] {
@table.Cell() {
{menu}
{menu.Text}
}
}
}

View File

@@ -14,14 +14,14 @@ import (
"github.com/b2dennis/meshi/xlsx"
)
var weekdays = [7]string{
var weekdays = []string{
"Sonntag",
"Montag",
"Dienstag",
"Mittwoch",
"Donnerstag",
"Freitag",
"Samstag",
"Sonntag",
}
func Home(plan xlsx.Plan) templ.Component {
@@ -109,7 +109,7 @@ func Home(plan xlsx.Plan) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "Wochentag")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "Tag")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -209,7 +209,7 @@ func Home(plan xlsx.Plan) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for i, day := range weekdays {
for i := 0; i <= 6; i++ {
class := ""
if i == 6 {
class = "border-b-0"
@@ -239,22 +239,35 @@ func Home(plan xlsx.Plan) templ.Component {
}
ctx = templ.InitializeContext(ctx)
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(day)
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(weekdays[plan[i][0].Date.Weekday()])
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/pages/home.templ`, Line: 56, Col: 36}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/pages/home.templ`, Line: 56, Col: 68}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, ", ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 string
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(plan[i][0].Date.Format("02.01.2006"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/pages/home.templ`, Line: 56, Col: 108}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = table.Cell().Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, menu := range plan.Menus[i] {
templ_7745c5c3_Var13 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
for _, menu := range plan[i] {
templ_7745c5c3_Var14 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
@@ -266,18 +279,18 @@ func Home(plan xlsx.Plan) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(menu)
var templ_7745c5c3_Var15 string
templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(menu.Text)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/pages/home.templ`, Line: 60, Col: 41}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/pages/home.templ`, Line: 60, Col: 46}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = table.Cell().Render(templ.WithChildren(ctx, templ_7745c5c3_Var13), templ_7745c5c3_Buffer)
templ_7745c5c3_Err = table.Cell().Render(templ.WithChildren(ctx, templ_7745c5c3_Var14), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@@ -301,7 +314,7 @@ func Home(plan xlsx.Plan) templ.Component {
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</body></html>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</body></html>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}