implement @ahocevar's suggestion instead
This commit is contained in:
@@ -15,6 +15,13 @@
|
||||
*/
|
||||
OpenLayers.Date = {
|
||||
|
||||
/**
|
||||
* APIProperty: regex
|
||||
* The regex to be used for validating dates. You can provide your own
|
||||
* regex for instance for adding support for years before BC.
|
||||
*/
|
||||
regex: /^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:(?:T(\d{1,2}):(\d{2}):(\d{2}(?:\.\d+)?)(Z|(?:[+-]\d{1,2}(?::(\d{2}))?)))|Z)?$/,
|
||||
|
||||
/**
|
||||
* APIMethod: toISOString
|
||||
* Generates a string representing a date. The format of the string follows
|
||||
@@ -91,7 +98,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(this.regex);
|
||||
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