Making date parsing a bit more lenient.
RFC 3339 doesn't say what timezone to assume for date strings without time. Some servers append "Z" to dates (e.g. "2001-02-03Z") and some clients accept this (e.g. Chrome). The OpenLayers date parser now accepts dates without times and with "Z" at the end.
This commit is contained in:
@@ -87,7 +87,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}))?)))?$/);
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user