diff --git a/internal/booking/service.go b/internal/booking/service.go index 961f990..2ee113b 100644 --- a/internal/booking/service.go +++ b/internal/booking/service.go @@ -166,7 +166,7 @@ func (bs Service) BuildReport(period string, month, year int) *Report { group by bookings.id order by bookings.id; `, - startDate.Format("2006-01-02"), endDate.Format("2006-01-02")). + startDate.Format(time.DateOnly), endDate.Format(time.DateOnly)). Scan(&lines) cardTotal := 0.0 diff --git a/internal/server/handle_bookings.go b/internal/server/handle_bookings.go index 476d0d6..250b4cb 100644 --- a/internal/server/handle_bookings.go +++ b/internal/server/handle_bookings.go @@ -26,8 +26,8 @@ func handleListBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFun return &view.ListBookingsViewModel{ Id: b.InvoiceNumber(hc), Url: templ.SafeURL(fmt.Sprintf("%s/%d", constant.RouteBooking, b.Id)), - From: b.From.Format("2006-01-02"), - To: b.To.Format("2006-01-02"), + From: b.From.Format(time.DateOnly), + To: b.To.Format(time.DateOnly), Platform: b.Platform, Name: b.CustomerName, Total: strconv.FormatFloat(b.Total, 'f', 2, 64), @@ -90,8 +90,8 @@ func handleBookingPage(bs *booking.Service, hc *config.Host) echo.HandlerFunc { PhoneNumber: b.PhoneNumber, CustomerNumber: strconv.Itoa(b.CustomerNumber), Email: b.Email, - From: b.From.Format("2006-01-02"), - To: b.To.Format("2006-01-02"), + From: b.From.Format(time.DateOnly), + To: b.To.Format(time.DateOnly), Platform: b.Platform, PlatformFees: strconv.FormatFloat(b.PlatformFees, 'f', 2, 64), Url: templ.EscapeString(fmt.Sprintf("%s/%d", constant.RouteBooking, b.Id)), @@ -153,8 +153,8 @@ func handleUpdateBooking(bs *booking.Service, hc *config.Host) echo.HandlerFunc PhoneNumber: b.PhoneNumber, CustomerNumber: strconv.Itoa(b.CustomerNumber), Email: b.Email, - From: b.From.Format("2006-01-02"), - To: b.To.Format("2006-01-02"), + From: b.From.Format(time.DateOnly), + To: b.To.Format(time.DateOnly), Platform: b.Platform, Platforms: hc.Platforms, PlatformFees: strconv.FormatFloat(b.PlatformFees, 'f', 2, 64), diff --git a/internal/server/handle_reports.go b/internal/server/handle_reports.go index cf7eac2..72e75a2 100644 --- a/internal/server/handle_reports.go +++ b/internal/server/handle_reports.go @@ -77,8 +77,8 @@ func handleComputeReport(bs *booking.Service, hc *config.Host) echo.HandlerFunc Url: templ.SafeURL(fmt.Sprintf("%s/%d", constant.RouteBooking, l.Id)), Total: strconv.FormatFloat(l.Total, 'f', 2, 64), CustomerName: l.CustomerName, - From: l.From.Format("2006-01-02"), - To: l.To.Format("2006-01-02"), + From: l.From.Format(time.DateOnly), + To: l.To.Format(time.DateOnly), Platform: l.Platform, PlatformFees: strconv.FormatFloat(l.PlatformFees, 'f', 2, 64), Fee: strconv.FormatFloat(l.Fee(), 'f', 2, 64), diff --git a/pkg/time/time.go b/pkg/time/time.go index 690f0de..20c25c5 100644 --- a/pkg/time/time.go +++ b/pkg/time/time.go @@ -1,9 +1,11 @@ package time -import "time" +import ( + "time" +) func ParseFromForm(src string) (time.Time, error) { - ts, err := time.Parse("2006-01-02", src) + ts, err := time.Parse(time.DateOnly, src) if err != nil { return time.Time{}, err }