Skip to content

Commit

Permalink
expression: adjust DST for convert_tz() (#37206) (#37955)
Browse files Browse the repository at this point in the history
close #30081
  • Loading branch information
ti-srebot committed Oct 28, 2022
1 parent 5d2030e commit 66494ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion expression/builtin_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -5957,7 +5957,7 @@ func (b *builtinConvertTzSig) convertTz(dt types.Time, fromTzStr, toTzStr string
}
}

t, err := dt.GoTime(fromTz)
t, err := dt.AdjustedGoTime(fromTz)
if err != nil {
return types.ZeroTime, true, nil
}
Expand Down
2 changes: 1 addition & 1 deletion expression/builtin_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2730,7 +2730,7 @@ func TestConvertTz(t *testing.T) {
{"2021-10-31 02:59:59", "Europe/Amsterdam", "+02:00", true, "2021-10-31 03:59:59"},
{"2021-10-31 02:00:00", "Europe/Amsterdam", "+01:00", true, "2021-10-31 02:00:00"},
{"2021-10-31 03:00:00", "Europe/Amsterdam", "+01:00", true, "2021-10-31 03:00:00"},
{"2021-03-28 02:30:00", "Europe/Amsterdam", "UTC", true, ""},
{"2021-03-28 02:30:00", "Europe/Amsterdam", "UTC", true, "2021-03-28 01:00:00"},
{"2021-10-22 10:00:00", "Europe/Tallinn", "SYSTEM", true, t1.In(loc2).Format("2006-01-02 15:04:00")},
{"2021-10-22 10:00:00", "SYSTEM", "Europe/Tallinn", true, t2.In(loc1).Format("2006-01-02 15:04:00")},
}
Expand Down
11 changes: 11 additions & 0 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7119,6 +7119,17 @@ func TestIssue28739(t *testing.T) {
"<nil> <nil>"))
}

func TestIssue30081(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec(`USE test`)
tk.MustQuery(`SELECT CONVERT_TZ('2007-03-11 2:00:00','US/Eastern','US/Central');`).
Check(testkit.Rows(`2007-03-11 01:00:00`))
tk.MustQuery(`SELECT CONVERT_TZ('2007-03-11 3:00:00','US/Eastern','US/Central');`).
Check(testkit.Rows(`2007-03-11 01:00:00`))
}

func TestIssue30326(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
Expand Down

0 comments on commit 66494ba

Please sign in to comment.