Skip to content

Commit

Permalink
feat: fix the problem
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Dec 26, 2024
1 parent 44c1dc2 commit a2e1ffb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
5 changes: 1 addition & 4 deletions go/mysql/datetime/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,7 @@ func (u fmtWeek0) parse(t *timeparts, bytes string) (string, bool) {
type fmtWeek1 struct{}

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

Expand Down
18 changes: 17 additions & 1 deletion go/vt/vtgate/evalengine/compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,25 @@ func TestCompilerSingle(t *testing.T) {
result: `VARBINARY("\x00\x00\x00\xff")`,
},
{
expression: `DATE_FORMAT(timestamp '2024-12-30 10:34:58', "%u");`,
expression: `DATE_FORMAT(timestamp '2024-12-30 10:34:58', "%u")`,
result: `VARCHAR("53")`,
},
{
expression: `WEEK(timestamp '2024-12-30 10:34:58', 0)`,
result: `INT64(52)`,
},
{
expression: `WEEK(timestamp '2024-12-30 10:34:58', 1)`,
result: `INT64(53)`,
},
{
expression: `WEEK(timestamp '2024-01-01 10:34:58', 0)`,
result: `INT64(0)`,
},
{
expression: `WEEK(timestamp '2024-01-01 10:34:58', 1)`,
result: `INT64(1)`,
},
}

tz, _ := time.LoadLocation("Europe/Madrid")
Expand Down

0 comments on commit a2e1ffb

Please sign in to comment.