GithubHelp home page GithubHelp logo

Comments (9)

matthewmueller avatar matthewmueller commented on May 28, 2024

oh interesting, yah this is definitely a bug. the morning default of 8am should have been overwritten in the last example

from date.

bulkan avatar bulkan commented on May 28, 2024

I've been trying to look into fixing this bug, but getting stuck as the rAtHour wont run for date("tomorrow at 9 in the morning") wont find any matches.

@matthewmueller any tips to where to look ?

from date.

matthewmueller avatar matthewmueller commented on May 28, 2024

Does it execute: https://github.com/MatthewMueller/date/blob/master/lib/parser.js#L307 ?

from date.

bulkan avatar bulkan commented on May 28, 2024

the function athour does execute but the rAtHour regex doesn't find any matches

the following prints null

var dateStr = "at 9 in morning"
var rAtHour = /^at\s?(\d{1,2})$/;
console.log(rAtHour.exec(dateStr));

from date.

matthewmueller avatar matthewmueller commented on May 28, 2024

Ah okay, well that wouldn't execute because it has the $ on the end.

The athour function should receive the string at 9 though, which should match.

from date.

bulkan avatar bulkan commented on May 28, 2024

Oh my example had the wrong dateStr

Now that you mention that, this.str progressively becomes the following;

test string is "tomorrow at 9 in the morning

at 9 in the morning
9 in the morning
in the morning
the morning

this explains why the rAtHour regex doesn't run. Looking at the execution of the functions in order

  • tomorrow
  • string
  • number
  • string
  • string
  • morning

from date.

bulkan avatar bulkan commented on May 28, 2024

@matthewmueller i've fixed this issue by doing this bulkan@749941d.

Probably, a better way would be to peek back once from the number and see if the token is at

from date.

bulkan avatar bulkan commented on May 28, 2024

Hey @matthewmueller should I submit a pull request for the changes in bulkan@749941d

from date.

matthewmueller avatar matthewmueller commented on May 28, 2024

@bulkan yep, then i can review

from date.

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.