Open tomcooksey opened 12 years ago
Looks like the error is here:
else if ((modules = TempusParsers[aType])) {
for (var i = 0, module; module = modules[i]; ++i) {
var exC = module.length;
if (ar.length < module.length) continue;
if (exC > 1) {
while (exC--) {
if (ar[exC] !== undef && realTypeOf(ar[exC]) != module.exp[exC]) {
continue;
}
}
}
if (module.test.apply(this, ar)) {
this._date = new Date();
this.setTimezoneToLocale();
return module.parse.apply(this, arguments);
}
}
Trying to match a module when no match you're not throwing.
Latest version throws nicer error, but still think that timestamp should be considered valid.
The date 2012-04-29 23:06:00
is not getting parsed because there are no registered parsers for it.
This date is a flavour of ISO8601, and can currently be parsed by the Date()
object in modern browsers.
Tempus should be better at parsing ISO8601 flavours, as it only deals with a limited subset, this is related to issue #13
On 0.1(a) this throws an obscure error, in the upcoming 0.2 this will throw an error like Error: Cannot parse '2012-04-29 23:06:00' with 'ISO8601Date,ISO8601,COOKIE,RFC822,RFC850,RFC1036,RFC1123,RFC2822,RFC3339,RSS,W3C,Locale,GMT,NCC1701'
which is more appropriate.
There are two possible quick solutions to this dilema.
2012-04-29T23:06:00Z
will be parsed, as this is the current incarnation of ISO8601 that Tempus passes var d = new Tempus('2012-04-29 23:06:00', '%Y-%m-%d %T');
If you're willing to wait until 0.2 is released then the problem should be resolved by then
Browser: Google Chrome V 18.0.1025.163 O/S: OSX 10.7.2