Comments (3)
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.
from tempus.
Latest version throws nicer error, but still think that timestamp should be considered valid.
from tempus.
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.
- If you are in control of the dates you receive, then make some adjustments to the format, a date like
2012-04-29T23:06:00Z
will be parsed, as this is the current incarnation of ISO8601 that Tempus passes - Use a custom formatter when newing up the date, this is as simple as changing the arguments to:
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
from tempus.
Related Issues (20)
- Regexp testing with g modifier HOT 4
- Better ISO8601 Support (microseconds)
- Documentation issue HOT 1
- toString parameters not as specified in docs HOT 1
- Year off by 1 in tz -07:00 HOT 12
- year doc is wrong HOT 1
- Tempus parsing of ISO8601 strings loses a day HOT 2
- Broken Link: "http://tempus-js.com/docs/browser-using-with-amd" HOT 1
- Feature request: timeString to autocomplete partially specified time strings HOT 1
- Missing "Developer preface" HOT 2
- Broken Link: "http://tempus-js.com/docs/developer-preface"
- Broken Link: "http://tempus-js.com/docs/node-getting-started"
- Broken Link: "http://tempus-js.com/docs/date-formatting"
- Set day with string
- Broken Link: "http://tempus-js.com/docs/date-formatting"
- Failure testing index.html HOT 1
- Thinking of making a pull request? HOT 2
- Broken Link: "http://tempus-js.com/docs/detailed-overview"
- Broken Link: "http://tempus-js.com/docs/developing-with-tdd"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tempus.