Pass the calendar days to the database as strings

Otherwise, it “helpfully” transforms the hours to UTC+02:00, in my case,
and returns a day extra, fucking up the request for the next sis months,
skipping almost a whole month.
This commit is contained in:
jordi fita mas 2023-12-21 22:51:12 +01:00
parent adf87fce94
commit 242e2b1c45
1 changed files with 2 additions and 1 deletions

View File

@ -236,13 +236,14 @@ var longMonthNames = []string{
func CollectSeasonCalendar(ctx context.Context, company *auth.Company, conn *database.Conn, year int, firstMonth time.Month, monthCount int) (*Calendar, error) {
firstDay := time.Date(year, firstMonth, 1, 0, 0, 0, 0, time.UTC)
lastDay := firstDay.AddDate(0, monthCount, 0).Add(-1 * time.Second)
fmt.Println(lastDay)
rows, err := conn.Query(ctx, `
select t.day::date
, to_color(coalesce(color, $1)) as color
from generate_series($2, $3, interval '1 day') as t(day)
left join season_calendar on season_range @> t.day::date
left join season on season.season_id = season_calendar.season_id and company_id = $4
`, UnsetColor, firstDay, lastDay, company.ID)
`, UnsetColor, firstDay.Format("2006-01-02 15:04:05"), lastDay.Format("2006-01-02 15:04:05"), company.ID)
if err != nil {
return nil, err
}