Giter VIP home page Giter VIP logo

Comments (3)

olivernn avatar olivernn commented on May 12, 2024

It's not a known test failure and the only set up step you missed was being in a timezone far from UTC 😉

lunr.tokenizer will convert any object (except arrays) you pass to it into a string that can later be indexed. It does this by calling toString on the passed object.

In JavaScript, calling toString on a date will convert it into your local timezone before generating the string representation. When you run the tests, I presume at some negative offset from UTC, it will convert the UTC date into your local date time, meaning that it is actually the previous day (and year in this case).

So, what should the correct behaviour be? Is the test or implementation wrong? I think the test is wrong here, if I give lunr a date to index I don't think it should be changing the timezone of the date before indexing. Instead of trying to create a date from UTC the test should just create a date in the local timezone, I think.

I'll fix the test so that this doesn't happen, thanks for taking the time to point it out, timezones are tricky!

from lunr.js.

smikes avatar smikes commented on May 12, 2024

Is this believed fixed or still open? Just ran into it today, timezone is America/Edmonton, reproduce it like this:

$ TZ=/usr/share/zoneinfo/America/Edmonton  npm test

> [email protected] test /Users/smikes/src/github/lunr.js
> make test

Starting test server at http://localhost:32423
Test failed: lunr.tokenizer: calling to string on passed val
    Failed assertion: expected: tue,jan,01,2013, but was: mon,dec,31,2012
    at http://localhost:32423/test/env/qunit.js:472
    at http://localhost:32423/test/tokenizer_test.js:50
    at http://localhost:32423/test/env/qunit.js:136
    at http://localhost:32423/test/env/qunit.js:279
    at process (http://localhost:32423/test/env/qunit.js:1277)
    at http://localhost:32423/test/env/qunit.js:383
Took 54ms to run 301 tests. 300 passed, 1 failed.

All tests pass if I use a TZ east of prime meridian, eg TZ=/usr/share/zoneinfo/Europe/Paris

from lunr.js.

olivernn avatar olivernn commented on May 12, 2024

There has been another fix for this issue pushed in the latest release, 0.5.8.

Feel free to re-open if you continue to see similar issues.

from lunr.js.

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.