allow for negative years in dates
This commit is contained in:
@@ -91,7 +91,7 @@ OpenLayers.Date = {
|
||||
*/
|
||||
parse: function(str) {
|
||||
var date;
|
||||
var match = str.match(/^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/);
|
||||
var match = str.match(/^(?:(-?\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/);
|
||||
if (match && (match[1] || match[7])) { // must have at least year or time
|
||||
var year = parseInt(match[1], 10) || 0;
|
||||
var month = (parseInt(match[2], 10) - 1) || 0;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
function test_Date_parse(t) {
|
||||
|
||||
t.plan(114);
|
||||
t.plan(121);
|
||||
|
||||
var cases = {
|
||||
"2000": {
|
||||
@@ -139,6 +139,11 @@
|
||||
year: 2000,
|
||||
month: 3,
|
||||
date: 15
|
||||
},
|
||||
"-0501-03-01T00:00:00.000Z": {
|
||||
year: -501,
|
||||
month: 2,
|
||||
date: 1
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user