Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-types

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-types - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

14

lib/textParsers.js

@@ -42,5 +42,6 @@ var arrayParser = require(__dirname + "/arrayParser.js");

//+06:30
var tZone = /([Z|+\-])(\d{2})?:?(\d{2})?/.exec(isoDate.split(' ')[1]);
var tZone = /([Z|+\-])(\d{2})?:?(\d{2})?:?(\d{2})?/.exec(isoDate.split(' ')[1]);
//minutes to adjust for timezone
var tzAdjust = 0;
var tzSign = 1;
var date;

@@ -53,6 +54,9 @@ if(tZone) {

case '-':
tzAdjust = -(((parseInt(tZone[2],10)*60)+(parseInt(tZone[3]||0,10))));
break;
tzSign = -1;
case '+':
tzAdjust = (((parseInt(tZone[2],10)*60)+(parseInt(tZone[3]||0,10))));
tzAdjust = tzSign * (
(parseInt(tZone[2], 10) * 3600) +
(parseInt(tZone[3] || 0, 10) * 60) +
(parseInt(tZone[4] || 0, 10))
);
break;

@@ -65,3 +69,3 @@ default:

date = new Date(utcOffset - (tzAdjust * 60* 1000));
date = new Date(utcOffset - (tzAdjust * 1000));
}

@@ -68,0 +72,0 @@ //no timezone information

{
"name": "pg-types",
"version": "1.3.0",
"version": "1.4.0",
"description": "Query result type converters for node-postgres",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,3 +0,4 @@

var parse = require('../').getTypeParser(1114, 'text');
var assert = require('./assert')
/*global describe, it*/
var parse = require("../").getTypeParser(1114, "text");
var assert = require("./assert");

@@ -7,5 +8,8 @@ //some of these tests might be redundant

//regardles: more tests is a good thing, right? :+1:
describe('date parser', function() {
it('parses date', function() {
assert.equal(parse("2010-12-11 09:09:04").toString(),new Date("2010-12-11 09:09:04").toString());
describe("date parser", function() {
it("parses date", function() {
assert.equal(
parse("2010-12-11 09:09:04").toString(),
new Date("2010-12-11 09:09:04").toString()
);
});

@@ -15,29 +19,69 @@

var dateString = "2010-01-01 01:01:01" + part;
it('testing for correcting parsing of ' + dateString, function() {
it("testing for correcting parsing of " + dateString, function() {
var ms = parse(dateString).getMilliseconds();
assert.equal(ms, expected)
})
}
assert.equal(ms, expected);
});
};
testForMs('.1', 100);
testForMs('.01', 10);
testForMs('.74', 740);
testForMs(".1", 100);
testForMs(".01", 10);
testForMs(".74", 740);
it("dates without timezones", function() {
var actual = "2010-12-11 09:09:04.1";
var expected = JSON.stringify(new Date(2010,11,11,9,9,4,100))
assert.equal(JSON.stringify(parse(actual)),expected);
});
describe("parses dates with", function () {
it("with timezones", function() {
var actual = "2011-01-23 22:15:51.28-06";
var expected = "\"2011-01-24T04:15:51.280Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
it("no timezones", function() {
var actual = "2010-12-11 09:09:04.1";
var expected = JSON.stringify(new Date(2010,11,11,9,9,4,100));
assert.equal(JSON.stringify(parse(actual)),expected);
});
it("huge millisecond value", function() {
var actual = "2011-01-23 22:15:51.280843-06";
var expected = "\"2011-01-24T04:15:51.280Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
});
it("Zulu time offset", function() {
var actual = "2011-01-23 22:15:51Z";
var expected = "\"2011-01-23T22:15:51.000Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
});
it("positive hour offset", function() {
var actual = "2011-01-23 10:15:51+04";
var expected = "\"2011-01-23T06:15:51.000Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
});
it("negative hour offset", function() {
var actual = "2011-01-23 10:15:51-04";
var expected = "\"2011-01-23T14:15:51.000Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
});
it("positive HH:mm offset", function() {
var actual = "2011-01-23 10:15:51+06:10";
var expected = "\"2011-01-23T04:05:51.000Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
});
it("negative HH:mm offset", function() {
var actual = "2011-01-23 10:15:51-06:10";
var expected = "\"2011-01-23T16:25:51.000Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
});
it("positive HH:mm:ss offset", function() {
var actual = "0005-02-03 10:53:28+01:53:28";
var expected = "\"0005-02-03T09:00:00.000Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
});
it("negative HH:mm:ss offset", function() {
var actual = "0005-02-03 09:58:45-02:01:15";
var expected = "\"0005-02-03T12:00:00.000Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
});
});
it("with huge millisecond value", function() {
var actual = "2011-01-23 22:15:51.280843-06";
var expected = "\"2011-01-24T04:15:51.280Z\"";
assert.equal(JSON.stringify(parse(actual)),expected);
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc