Use Date instead of Time for dates
This commit is contained in:
@ -5,10 +5,10 @@ import (
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"crawshaw.io/sqlite"
|
||||
"crawshaw.io/sqlite/sqlitex"
|
||||
"github.com/rickb777/date"
|
||||
)
|
||||
|
||||
type GenString func(length int) (string, error)
|
||||
@ -118,9 +118,9 @@ func (s *Store) createSchema() error {
|
||||
}
|
||||
|
||||
type CreateEventCommand struct {
|
||||
Name string
|
||||
Description string
|
||||
EarliestDate, LatestDate time.Time
|
||||
Name string
|
||||
Description string
|
||||
Earliest, Latest date.Date
|
||||
}
|
||||
|
||||
type CreateEventResult struct {
|
||||
@ -154,8 +154,8 @@ func (s *Store) CreateEvent(ctx context.Context, cmd CreateEventCommand) (result
|
||||
adminCode,
|
||||
cmd.Name,
|
||||
cmd.Description,
|
||||
cmd.EarliestDate.Format(dbDateLayout),
|
||||
cmd.LatestDate.Format(dbDateLayout),
|
||||
cmd.Earliest.Format(dbDateLayout),
|
||||
cmd.Latest.Format(dbDateLayout),
|
||||
)
|
||||
if err != nil {
|
||||
return
|
||||
@ -171,9 +171,9 @@ type GetEventMetadataQuery struct {
|
||||
}
|
||||
|
||||
type GetEventMetadataResult struct {
|
||||
Name string
|
||||
Description string
|
||||
EarliestDate, LatestDate time.Time
|
||||
Name string
|
||||
Description string
|
||||
Earliest, Latest date.Date
|
||||
}
|
||||
|
||||
func (s *Store) GetEventMetadata(ctx context.Context, query GetEventMetadataQuery) (GetEventMetadataResult, error) {
|
||||
@ -196,11 +196,11 @@ func (s *Store) GetEventMetadata(ctx context.Context, query GetEventMetadataQuer
|
||||
latestDateString := stmt.ColumnText(3)
|
||||
|
||||
var err error
|
||||
result.EarliestDate, err = time.Parse(dbDateLayout, earliestDateString)
|
||||
result.Earliest, err = date.Parse(dbDateLayout, earliestDateString)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
result.LatestDate, err = time.Parse(dbDateLayout, latestDateString)
|
||||
result.Latest, err = date.Parse(dbDateLayout, latestDateString)
|
||||
return err
|
||||
}, query.AlphaID)
|
||||
if err != nil {
|
||||
@ -242,7 +242,7 @@ func (s *Store) GetEventResponses(ctx context.Context, query GetEventResponsesQu
|
||||
|
||||
type CreateEventResponseCommand struct {
|
||||
EventAlphaID string
|
||||
DateHours map[time.Time]int
|
||||
DateHours map[date.Date]int
|
||||
}
|
||||
|
||||
type CreateEventResponseResult struct {
|
||||
|
Reference in New Issue
Block a user