use std lib for time formatting

This commit is contained in:
Ruidy 2024-04-12 17:31:24 +02:00
parent 641605098f
commit 65423c176a
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
4 changed files with 13 additions and 11 deletions

View file

@ -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

View file

@ -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),

View file

@ -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),

View file

@ -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
}