Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"100 days ago" not working #79

Open
shichao-an opened this issue May 15, 2016 · 5 comments
Open

"100 days ago" not working #79

shichao-an opened this issue May 15, 2016 · 5 comments

Comments

@shichao-an
Copy link

"100 days ago" or (>= 100 days ago) results in 1:00 a.m. today.
"99 days" or (<= 99 days ago) is working correctly.

@mirkods
Copy link

mirkods commented Aug 31, 2017

any update on this?

@gautaz
Copy link

gautaz commented Mar 16, 2018

Hello,

The issue seems the same whatever time unit is used, i.e.:

> ['now', 'in 30 seconds', 'in 60 seconds', 'in 99 seconds', 'in 100 seconds'].map(d => console.log(date(d)))
2018-03-16T14:44:24.751Z
2018-03-16T14:44:54.751Z
2018-03-16T14:45:24.756Z
2018-03-16T14:46:03.757Z
2018-03-17T00:00:00.757Z

The maintainer has probably not so much time to fix this, a merge request is probably welcome.
@matthewmueller I'll look into it if I have some time.

@gautaz
Copy link

gautaz commented Mar 16, 2018

This issue seems hard to fix without major modifications.

From my current understanding:

  • the library is implemented through the use of a context-free grammar;
  • ago or in words basically change the way the tokenizer should (and cannot) extract tokens.

Currently the tokenizer extracts 100 as if it was 1 hour and 00 minutes which results in a replacement of 100 by the token 01:00, this later token is recognized as an hourMinute token.

From my point of view, this should at least result in an error instead of a bad result.
100 days ago is recognized by the library as 1 hour 00 minutes days ago which seems to be an incorrect way of detailing a past event.

Another way to deal with this would be to systematically interpret plain numbers as periods of time and not as points in time but that would break things like today at 705 pm (I would rather use today at 7:05 pm).

@steel-maker
Copy link

steel-maker commented Aug 10, 2018

Hello

As a workaround, you can split the number of days in multiples series of 'in n days' where n is <100.

ex: instead of doing:
date('in 200 days at 7:00pm)
you can do:
date('in 50 days in 50 days in 50 days in 50 days at 7:00pm')
or:
date('in 99 days in 99 days in 2 days at 7:00pm')

I know it's ugly but it work :)

tested in the project frontpage and with google

@danyfedorov
Copy link

@matthewmueller Maybe add a note about this to the documentation? Like your numbers must be <100!!!. This is a very unexpected thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants