Skip to content

Commit 8392099

Browse files
committed
times are now deserialized as time.Local
1 parent d6bb9b2 commit 8392099

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

stmt_test.go

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -438,19 +438,19 @@ func TestSelect(t *testing.T) {
438438
{"'abc'", string("abc")},
439439
{"cast(null as varchar(3))", nil},
440440
{"NULL", nil},
441-
{"cast('1753-01-01' as datetime)", time.Date(1753, 1, 1, 0, 0, 0, 0, time.UTC)},
442-
{"cast('2000-01-01' as datetime)", time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)},
441+
{"cast('1753-01-01' as datetime)", time.Date(1753, 1, 1, 0, 0, 0, 0, time.Local)},
442+
{"cast('2000-01-01' as datetime)", time.Date(2000, 1, 1, 0, 0, 0, 0, time.Local)},
443443
{"cast('2000-01-01T12:13:14.12' as datetime)",
444-
time.Date(2000, 1, 1, 12, 13, 14, 120000000, time.UTC)},
445-
{"cast('2014-06-26 11:08:09.673' as datetime)", time.Date(2014, 06, 26, 11, 8, 9, 673000000, time.UTC)},
446-
{"cast('9999-12-31T23:59:59.996' as datetime)", time.Date(9999, 12, 31, 23, 59, 59, 996000000, time.UTC)},
444+
time.Date(2000, 1, 1, 12, 13, 14, 120000000, time.Local)},
445+
{"cast('2014-06-26 11:08:09.673' as datetime)", time.Date(2014, 06, 26, 11, 8, 9, 673000000, time.Local)},
446+
{"cast('9999-12-31T23:59:59.996' as datetime)", time.Date(9999, 12, 31, 23, 59, 59, 996000000, time.Local)},
447447
{"cast(NULL as datetime)", nil},
448448
{"cast('1900-01-01T00:00:00' as smalldatetime)",
449-
time.Date(1900, 1, 1, 0, 0, 0, 0, time.UTC)},
449+
time.Date(1900, 1, 1, 0, 0, 0, 0, time.Local)},
450450
{"cast('2000-01-01T12:13:00' as smalldatetime)",
451-
time.Date(2000, 1, 1, 12, 13, 0, 0, time.UTC)},
451+
time.Date(2000, 1, 1, 12, 13, 0, 0, time.Local)},
452452
{"cast('2079-06-06T23:59:00' as smalldatetime)",
453-
time.Date(2079, 6, 6, 23, 59, 0, 0, time.UTC)},
453+
time.Date(2079, 6, 6, 23, 59, 0, 0, time.Local)},
454454
{"cast(NULL as smalldatetime)", nil},
455455
{"cast(0x1234 as varbinary(2))", []byte{0x12, 0x34}},
456456
{"cast(null as unitext)", nil},
@@ -849,15 +849,13 @@ func TestDateTimeParam(t *testing.T) {
849849
t.Fatal("create table failed")
850850
}
851851

852-
var emptydate time.Time
853-
mindate := time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)
854-
maxdate := time.Date(9999, 12, 31, 23, 59, 59, 999999900, time.UTC)
852+
mindate := time.Date(1, 1, 1, 0, 0, 0, 0, time.Local)
853+
maxdate := time.Date(9999, 12, 31, 23, 59, 59, 999999900, time.Local)
855854
values := []testStruct{
856-
{time.Date(1969, time.July, 20, 20, 18, 0, 0, time.UTC)}, // First man on the Moon
857-
{time.Date(1970, 1, 1, 0, 0, 0, 0, time.UTC)}, // UNIX date
858-
{time.Date(4, 6, 3, 12, 13, 14, 150000000, time.UTC)}, // some random date
855+
{time.Date(1969, time.July, 20, 20, 18, 0, 0, time.Local)}, // First man on the Moon
856+
{time.Date(1970, 1, 1, 0, 0, 0, 0, time.Local)}, // UNIX date
857+
{time.Date(4, 6, 3, 12, 13, 14, 150000000, time.Local)}, // some random date
859858
{mindate}, // minimal value
860-
{emptydate},
861859
}
862860
for _, test := range values {
863861
t.Run(fmt.Sprintf("Test for %v", test.t), func(t *testing.T) {

types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ func decodeDateTime(e *binary.Encoder, i colType) (interface{}, error) {
343343
if s != 0 {
344344
t = t.Add(time.Duration(s) * time.Second)
345345
}
346+
346347
return t, e.Err()
347348
}
348349

0 commit comments

Comments
 (0)