Skip to content

Commit

Permalink
Use the documented modes for the rest of the formatters
Browse files Browse the repository at this point in the history
To ensure we avoid additional bugs, always use the mode documented
instead if re-implementing something similar here.

Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink committed Dec 26, 2024
1 parent a2e1ffb commit e9f9d0b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions go/mysql/datetime/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,7 @@ func (t2 fmtFullTime24) parse(t *timeparts, bytes string) (string, bool) {
type fmtWeek0 struct{}

func (fmtWeek0) format(dst []byte, t DateTime, prec uint8) []byte {
year, week := t.Date.SundayWeek()
if year < t.Date.Year() {
week = 0
}
week := t.Date.Week(0)
return appendInt(dst, week, 2)
}

Expand All @@ -386,7 +383,7 @@ func (u fmtWeek1) parse(t *timeparts, bytes string) (string, bool) {
type fmtWeek2 struct{}

func (fmtWeek2) format(dst []byte, t DateTime, prec uint8) []byte {
_, week := t.Date.SundayWeek()
week := t.Date.Week(2)
return appendInt(dst, week, 2)
}

Expand All @@ -398,7 +395,7 @@ func (v fmtWeek2) parse(t *timeparts, bytes string) (string, bool) {
type fmtWeek3 struct{}

func (fmtWeek3) format(dst []byte, t DateTime, prec uint8) []byte {
_, week := t.Date.ISOWeek()
week := t.Date.Week(3)
return appendInt(dst, week, 2)
}

Expand Down

0 comments on commit e9f9d0b

Please sign in to comment.