Skip to content

Commit 615f1bb

Browse files
committed
Fixes test itself, nothing was wrong, just the test table and the tests
1 parent 05bd3ae commit 615f1bb

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

test/integration/connection/test-timezones.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ common.useTestDb(connection);
77
var table = 'timezone_test';
88
connection.query([
99
'CREATE TEMPORARY TABLE `' + table + '`(',
10-
'`offset` float,',
10+
'`offset` varchar(10),',
1111
'`dt` datetime',
1212
') ENGINE=InnoDB DEFAULT CHARSET=utf8'
1313
].join('\n'));
1414

15-
var tests = [ 0, 1, 5, 12, 26, -1, -5, -20, 'Z', 'local', undefined ];
15+
var tests = [ 0, 1, 5, 12, 26, -1, -5, -20, 'Z', 'local' ];
16+
17+
connection.query('DELETE FROM ' + table);
1618

1719
testNextDate();
1820

@@ -31,22 +33,21 @@ function testNextDate() {
3133
function testDate(offset, cb) {
3234
var dt = new Date();
3335

34-
if (offset == 'Z' || offset == 'local' || !offset) {
36+
if (offset == 'Z' || offset == 'local') {
3537
connection._timezone = offset;
3638
} else {
3739
connection._timezone = (offset < 0 ? "-" : "+") + pad2(Math.abs(offset)) + ":00";
3840
}
3941
connection.query('INSERT INTO ' + table + ' SET ?', { offset: offset, dt: dt });
4042

4143
if (offset == 'Z') {
42-
dt.setTime(dt.getTime() - (dt.getTimezoneOffset() * 60000));
43-
} else if (offset != 'local' && offset) {
44-
dt.setTime(dt.getTime() - (dt.getTimezoneOffset() * 60000) + (offset * 3600000));
44+
dt.setTime(dt.getTime() + (dt.getTimezoneOffset() * 60000));
45+
} else if (offset != 'local') {
46+
dt.setTime(dt.getTime() + (dt.getTimezoneOffset() * 60000) + (offset * 3600000));
4547
}
4648

4749
connection.query({
48-
sql: 'SELECT * FROM ' + table + ' WHERE offset ' + (offset === undefined ? 'IS NULL' : '= ?'),
49-
values: [ offset ],
50+
sql: 'SELECT * FROM ' + table + ' WHERE offset = \'' + offset + '\'',
5051
typeCast: function (field, parser, timeZone, next) {
5152
if (field.type != 12) return next();
5253

0 commit comments

Comments
 (0)