Comparing version 2.4.0 to 2.5.0
@@ -0,1 +1,7 @@ | ||
2.5.0 / 2019-01-23 | ||
================== | ||
* Support timezone offset without colon | ||
* Support negative timezone offset with minus sign | ||
* Use system timezone when given time without offset | ||
2.4.0 / 2018-11-12 | ||
@@ -2,0 +8,0 @@ ================== |
{ | ||
"name": "edtf", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Extended Date Time Format (EDTF) / ISO 8601-2 Parser and Library", | ||
@@ -37,8 +37,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"nearley": "^2.15.1", | ||
"randexp": "^0.4.9" | ||
"nearley": "^2.16.0", | ||
"randexp": "^0.5.3" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"eslint": "^4.19.1", | ||
"eslint": "^5.12.0", | ||
"istanbul": "^0.4.3", | ||
@@ -45,0 +45,0 @@ "mocha": "^5.2.0" |
@@ -1,2 +0,2 @@ | ||
// Generated automatically by nearley, version 2.15.1 | ||
// Generated automatically by nearley, version 2.16.0 | ||
// http://github.com/Hardmath123/nearley | ||
@@ -68,7 +68,12 @@ (function () { | ||
{"name": "timezone", "symbols": [{"literal":"Z"}], "postprocess": zero}, | ||
{"name": "timezone", "symbols": [{"literal":"-"}, "offset"], "postprocess": data => -data[1]}, | ||
{"name": "timezone$subexpression$1", "symbols": [{"literal":"-"}]}, | ||
{"name": "timezone$subexpression$1", "symbols": [{"literal":"−"}]}, | ||
{"name": "timezone", "symbols": ["timezone$subexpression$1", "offset"], "postprocess": data => -data[1]}, | ||
{"name": "timezone", "symbols": [{"literal":"+"}, "positive_offset"], "postprocess": pick(1)}, | ||
{"name": "positive_offset", "symbols": ["offset"], "postprocess": id}, | ||
{"name": "positive_offset$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}, {"literal":":"}, {"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "positive_offset", "symbols": ["positive_offset$string$1"], "postprocess": zero}, | ||
{"name": "positive_offset$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "positive_offset$ebnf$1", "symbols": [{"literal":":"}], "postprocess": id}, | ||
{"name": "positive_offset$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "positive_offset$string$2", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "positive_offset", "symbols": ["positive_offset$string$1", "positive_offset$ebnf$1", "positive_offset$string$2"], "postprocess": zero}, | ||
{"name": "positive_offset$subexpression$1$string$1", "symbols": [{"literal":"1"}, {"literal":"2"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
@@ -78,11 +83,23 @@ {"name": "positive_offset$subexpression$1", "symbols": ["positive_offset$subexpression$1$string$1"]}, | ||
{"name": "positive_offset$subexpression$1", "symbols": ["positive_offset$subexpression$1$string$2"]}, | ||
{"name": "positive_offset", "symbols": ["positive_offset$subexpression$1", {"literal":":"}, "minutes"], "postprocess": data => num(data[0]) * 60 + data[2]}, | ||
{"name": "positive_offset$string$2", "symbols": [{"literal":"1"}, {"literal":"4"}, {"literal":":"}, {"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "positive_offset", "symbols": ["positive_offset$string$2"], "postprocess": () => 840}, | ||
{"name": "positive_offset$ebnf$2", "symbols": [{"literal":":"}], "postprocess": id}, | ||
{"name": "positive_offset$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "positive_offset", "symbols": ["positive_offset$subexpression$1", "positive_offset$ebnf$2", "minutes"], "postprocess": data => num(data[0]) * 60 + data[2]}, | ||
{"name": "positive_offset$string$3", "symbols": [{"literal":"1"}, {"literal":"4"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "positive_offset$ebnf$3", "symbols": [{"literal":":"}], "postprocess": id}, | ||
{"name": "positive_offset$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "positive_offset$string$4", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "positive_offset", "symbols": ["positive_offset$string$3", "positive_offset$ebnf$3", "positive_offset$string$4"], "postprocess": () => 840}, | ||
{"name": "positive_offset", "symbols": ["d00_14"], "postprocess": data => num(data[0]) * 60}, | ||
{"name": "offset", "symbols": ["d01_11", {"literal":":"}, "minutes"], "postprocess": data => num(data[0]) * 60 + data[2]}, | ||
{"name": "offset$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}, {"literal":":"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "offset", "symbols": ["offset$string$1", "d01_59"], "postprocess": data => num(data[1])}, | ||
{"name": "offset$string$2", "symbols": [{"literal":"1"}, {"literal":"2"}, {"literal":":"}, {"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "offset", "symbols": ["offset$string$2"], "postprocess": () => 720}, | ||
{"name": "offset$ebnf$1", "symbols": [{"literal":":"}], "postprocess": id}, | ||
{"name": "offset$ebnf$1", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "offset", "symbols": ["d01_11", "offset$ebnf$1", "minutes"], "postprocess": data => num(data[0]) * 60 + data[2]}, | ||
{"name": "offset$string$1", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "offset$ebnf$2", "symbols": [{"literal":":"}], "postprocess": id}, | ||
{"name": "offset$ebnf$2", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "offset", "symbols": ["offset$string$1", "offset$ebnf$2", "d01_59"], "postprocess": data => num(data[2])}, | ||
{"name": "offset$string$2", "symbols": [{"literal":"1"}, {"literal":"2"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "offset$ebnf$3", "symbols": [{"literal":":"}], "postprocess": id}, | ||
{"name": "offset$ebnf$3", "symbols": [], "postprocess": function(d) {return null;}}, | ||
{"name": "offset$string$3", "symbols": [{"literal":"0"}, {"literal":"0"}], "postprocess": function joiner(d) {return d.join('');}}, | ||
{"name": "offset", "symbols": ["offset$string$2", "offset$ebnf$3", "offset$string$3"], "postprocess": () => 720}, | ||
{"name": "offset", "symbols": ["d01_12"], "postprocess": data => num(data[0]) * 60}, | ||
@@ -89,0 +106,0 @@ {"name": "L1", "symbols": ["L1d"], "postprocess": id}, |
@@ -101,5 +101,8 @@ 'use strict' | ||
datetime(data) { | ||
let offset = data[3] | ||
if (offset == null) offset = new Date().getTimezoneOffset() | ||
return { | ||
values: Bitmask.normalize(data[0].map(Number)).concat(data[2]), | ||
offset: data[3], | ||
offset, | ||
type: 'Date', | ||
@@ -106,0 +109,0 @@ level: 0 |
@@ -6,3 +6,10 @@ 'use strict' | ||
describe('ISO 8601-1', () => { | ||
let H, M | ||
before(() => { | ||
let offset = new Date().getTimezoneOffset() | ||
H = offset / 60 | ||
M = offset % 60 | ||
}) | ||
it('YYYY-MM-DD', () => | ||
@@ -13,43 +20,45 @@ expect(edtf('2005-05-31')).to.have.ymd([2005, 4, 31])) | ||
expect(edtf('2014-12-08T11:46:42')) | ||
.to.have.ymd([2014, 11, 8]).and.hms([11 + H, 46 + M, 42]) | ||
expect(edtf('2014-12-08T11:46:42Z')) | ||
.to.have.ymd([2014, 11, 8]).and.hms([11, 46, 42]) | ||
expect(edtf('1914-12-08T11:46:42')) | ||
expect(edtf('1914-12-08T11:46:42Z')) | ||
.to.have.ymd([1914, 11, 8]).and.hms([11, 46, 42]) | ||
expect(edtf('0014-12-08T11:46:42')) | ||
.to.have.ymd([14, 11, 8]).and.hms([11, 46, 42]) | ||
.to.have.ymd([14, 11, 8]).and.hms([11 + H, 46 + M, 42]) | ||
expect(edtf('1970-12-08T11:46:42')) | ||
expect(edtf('1970-12-08T11:46:42Z')) | ||
.to.have.ymd([1970, 11, 8]).and.hms([11, 46, 42]) | ||
expect(edtf('0070-12-08T11:46:42')) | ||
expect(edtf('0070-12-08T11:46:42Z')) | ||
.to.have.ymd([70, 11, 8]).and.hms([11, 46, 42]) | ||
expect(edtf('1974-12-08T11:46:42')) | ||
expect(edtf('1974-12-08T11:46:42Z')) | ||
.to.have.ymd([1974, 11, 8]).and.hms([11, 46, 42]) | ||
expect(edtf('0074-12-08T11:46:42')) | ||
expect(edtf('0074-12-08T11:46:42Z')) | ||
.to.have.ymd([74, 11, 8]).and.hms([11, 46, 42]) | ||
expect(edtf('1899-12-31T23:59:59')) | ||
expect(edtf('1899-12-31T23:59:59Z')) | ||
.to.have.ymd([1899, 11, 31]).and.hms([23, 59, 59]) | ||
expect(edtf('1899-12-31T24:00:00')) | ||
expect(edtf('1899-12-31T24:00:00Z')) | ||
.to.have.ymd([1900, 0, 1]).and.hms([0, 0, 0]) | ||
expect(edtf('1900-01-01T00:00:00')) | ||
expect(edtf('1900-01-01T00:00:00Z')) | ||
.to.have.ymd([1900, 0, 1]).and.hms([0, 0, 0]) | ||
expect(edtf('-0001-12-31T23:59:59')) | ||
expect(edtf('-0001-12-31T23:59:59Z')) | ||
.to.have.ymd([-1, 11, 31]).and.hms([23, 59, 59]) | ||
expect(edtf('-0001-12-31T24:00:00')) | ||
expect(edtf('-0001-12-31T24:00:00Z')) | ||
.to.have.ymd([0, 0, 1]).and.hms([0, 0, 0]) | ||
expect(edtf('0000-01-01T00:00:00')) | ||
expect(edtf('0000-01-01T00:00:00Z')) | ||
.to.have.ymd([0, 0, 1]).and.hms([0, 0, 0]) | ||
expect(edtf('0000-03-01T11:46:42')) | ||
expect(edtf('0000-03-01T11:46:42Z')) | ||
.to.have.ymd([0, 2, 1]).and.hms([11, 46, 42]) | ||
expect(edtf('0001-12-08T11:46:42')) | ||
expect(edtf('0001-12-08T11:46:42Z')) | ||
.to.have.ymd([1, 11, 8]).and.hms([11, 46, 42]) | ||
expect(edtf('1999-12-31T23:59:59')) | ||
expect(edtf('1999-12-31T23:59:59Z')) | ||
.to.have.ymd([1999, 11, 31]).and.hms([23, 59, 59]) | ||
expect(edtf('1999-12-31T24:00:00')) | ||
expect(edtf('1999-12-31T24:00:00Z')) | ||
.to.have.ymd([2000, 0, 1]).and.hms([0, 0, 0]) | ||
expect(edtf('2000-01-01T00:00:00')) | ||
expect(edtf('2000-01-01T00:00:00Z')) | ||
.to.have.ymd([2000, 0, 1]).and.hms([0, 0, 0]) | ||
@@ -61,3 +70,3 @@ }) | ||
.to.have.ymd([2014, 11, 8]) | ||
.and.hms([11, 46, 42]).and.ms(123)) | ||
.and.hms([11 + H, 46 + M, 42]).and.ms(123)) | ||
@@ -71,2 +80,11 @@ it('YYYY-MM-DDTHH:MM:SSZ', () => | ||
.to.have.ymd([2014, 11, 8]).and.hms([13, 46, 42])) | ||
it('YYYY-MM-DDTHH:MM:SS-02:00', () => { | ||
expect(edtf('2014-12-08T11:46:42-02:00')) | ||
.to.have.ymd([2014, 11, 8]).and.hms([9, 46, 42]) | ||
// Using minus sign! | ||
expect(edtf('2014-12-08T11:46:42−02:00')) | ||
.to.have.ymd([2014, 11, 8]).and.hms([9, 46, 42]) | ||
}) | ||
}) |
@@ -62,2 +62,5 @@ 'use strict' | ||
expect(() => p('2016-05-02T01:01:60')).to.be.rejected | ||
expect(p('2016-05-02T16:54:59')) | ||
.to.have.property('offset', new Date().getTimezoneOffset()) | ||
}) | ||
@@ -98,2 +101,25 @@ | ||
it('YYYY-MM-DDThh:mm:ss[+-]hhmm', () => { | ||
expect(p('2016-05-02T16:54:59+0230')) | ||
.to.produce([2016, 4, 2, 16, 54, 59]) | ||
.at.level(0) | ||
.and.have.property('offset', 150) | ||
expect(p('2016-05-02T16:54:59+0000')).to.have.property('offset', 0) | ||
expect(p('2016-05-02T16:54:59+1400')).to.have.property('offset', 840) | ||
expect(p('2016-05-02T16:54:59+1330')).to.have.property('offset', 810) | ||
expect(p('2016-05-02T16:54:59+1200')).to.have.property('offset', 720) | ||
expect(p('2016-05-02T16:54:59+0410')).to.have.property('offset', 250) | ||
expect(p('2016-05-02T16:54:59-0015')).to.have.property('offset', -15) | ||
expect(p('2016-05-02T16:54:59-1159')).to.have.property('offset', -719) | ||
expect(p('2016-05-02T16:54:59-1200')).to.have.property('offset', -720) | ||
expect(() => p('2016-05-02T12:00:00-0000')).to.be.rejected | ||
expect(() => p('2016-05-02T12:00:00-2000')).to.be.rejected | ||
expect(() => p('2016-05-02T12:00:00-1201')).to.be.rejected | ||
expect(() => p('2016-05-02T12:00:00-1300')).to.be.rejected | ||
expect(() => p('2016-05-02T12:00:00-1400')).to.be.rejected | ||
expect(() => p('2016-05-02T12:00:00+1401')).to.be.rejected | ||
}) | ||
it('YYYY-MM-DDThh:mm:ss[+-]hh', () => { | ||
@@ -100,0 +126,0 @@ expect(p('2016-05-02T16:54:59+14')) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
198641
3608
+ Addedrandexp@0.5.3(transitive)
- Removedrandexp@0.4.9(transitive)
Updatednearley@^2.16.0
Updatedrandexp@^0.5.3