Fix XSD parsing of non-Zulu times
This commit is contained in:
@@ -55,10 +55,10 @@ ol.format.XSD.readDateTime = function(node) {
|
||||
var second = parseInt(m[6], 10);
|
||||
var dateTime = Date.UTC(year, month, day, hour, minute, second) / 1000;
|
||||
if (m[7] != 'Z') {
|
||||
var sign = m[8] == '-' ? -1 : 1;
|
||||
dateTime += sign * 60 * parseInt(m[9], 10);
|
||||
var sign = m[8] == '-' ? 1 : -1;
|
||||
dateTime += sign * 60 * 60 * parseInt(m[9], 10);
|
||||
if (m[10] !== undefined) {
|
||||
dateTime += sign * 60 * 60 * parseInt(m[10], 10);
|
||||
dateTime += sign * 60 * parseInt(m[10], 10);
|
||||
}
|
||||
}
|
||||
return dateTime;
|
||||
|
||||
16
test/spec/ol/format/xsdformat.test.js
Normal file
16
test/spec/ol/format/xsdformat.test.js
Normal file
@@ -0,0 +1,16 @@
|
||||
goog.provide('ol.test.XSD');
|
||||
|
||||
describe('ol.format.XSD', function() {
|
||||
|
||||
describe('readDateTime', function() {
|
||||
it('can handle non-Zulu time zones', function() {
|
||||
var node = document.createElement('time');
|
||||
node.textContent = '2016-07-12T15:00:00+03:00';
|
||||
expect(new Date(ol.format.XSD.readDateTime(node) * 1000).toISOString()).to.eql('2016-07-12T12:00:00.000Z');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.format.XSD');
|
||||
Reference in New Issue
Block a user