node-postgres/test/integration/client/timezone-tests.js
Brian C 8798e50ad3 Re-enable eslint with standard format (#1367)
* Work on converting lib to standard

* Finish updating lib

* Finish linting lib

* Format test files

* Add .eslintrc with standard format

* Supply full path to eslint bin

* Move lint command to package.json

* Add eslint as dev dependency
2017-07-15 12:05:58 -05:00

35 lines
909 B
JavaScript

'use strict'
var helper = require('./../test-helper')
var exec = require('child_process').exec
var oldTz = process.env.TZ
process.env.TZ = 'Europe/Berlin'
var date = new Date()
const pool = new helper.pg.Pool()
const suite = new helper.Suite()
pool.connect(function (err, client, done) {
assert(!err)
suite.test('timestamp without time zone', function (cb) {
client.query('SELECT CAST($1 AS TIMESTAMP WITHOUT TIME ZONE) AS "val"', [date], function (err, result) {
assert(!err)
assert.equal(result.rows[0].val.getTime(), date.getTime())
cb()
})
})
suite.test('timestamp with time zone', function (cb) {
client.query('SELECT CAST($1 AS TIMESTAMP WITH TIME ZONE) AS "val"', [date], function (err, result) {
assert(!err)
assert.equal(result.rows[0].val.getTime(), date.getTime())
done()
pool.end(cb)
process.env.TZ = oldTz
})
})
})