Skip to content

Commit b7dc7f0

Browse files
committed
helpers: when escaping a date, avoid adding 'Z' if timezone is local (should fix dresende#50)
1 parent 26239cb commit b7dc7f0

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

lib/Helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module.exports.dateToString = function (date, timeZone, opts) {
3535
var second = zeroPad(dt.getSeconds());
3636
var milli = zeroPad(dt.getMilliseconds(), 3);
3737

38-
if (opts.dialect == 'mysql') {
38+
if (opts.dialect == 'mysql' || timeZone == 'local') {
3939
return year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second + '.' + milli;
4040
} else {
4141
return year + '-' + month + '-' + day + 'T' + hour + ':' + minute + ':' + second + '.' + milli + 'Z';

test/integration/test-dialect-mssql.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ assert.equal(
7171

7272
assert.equal(
7373
dialect.escapeVal(new Date(d.getTime() + tzOffsetMillis)),
74-
"'2013-09-04T19:15:11.133Z'"
74+
"'2013-09-04 19:15:11.133'"
7575
);
7676

7777
assert.equal(
@@ -103,4 +103,4 @@ assert.equal(
103103
assert.equal(
104104
dialect.limitAsTop,
105105
true
106-
);
106+
);

test/integration/test-dialect-postgresql.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ assert.equal(
7676

7777
assert.equal(
7878
dialect.escapeVal(new Date(d.getTime() + tzOffsetMillis)),
79-
"'2013-09-04T19:15:11.133Z'"
79+
"'2013-09-04 19:15:11.133'"
8080
);
8181

8282
assert.equal(
@@ -108,4 +108,4 @@ assert.equal(
108108
assert.equal(
109109
dialect.limitAsTop || false,
110110
false
111-
);
111+
);

test/integration/test-dialect-sqlite.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ assert.equal(
7171

7272
assert.equal(
7373
dialect.escapeVal(new Date(d.getTime() + tzOffsetMillis)),
74-
"'2013-09-04T19:15:11.133Z'"
74+
"'2013-09-04 19:15:11.133'"
7575
);
7676

7777
assert.equal(
@@ -103,4 +103,4 @@ assert.equal(
103103
assert.equal(
104104
dialect.limitAsTop || false,
105105
false
106-
);
106+
);

0 commit comments

Comments
 (0)