Giter VIP home page Giter VIP logo

Comments (3)

tomcooksey avatar tomcooksey commented on June 16, 2024

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.

tomcooksey avatar tomcooksey commented on June 16, 2024

Latest version throws nicer error, but still think that timestamp should be considered valid.

from tempus.

keithamus avatar keithamus commented on June 16, 2024

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.

  1. 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
  2. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.