chronic icon indicating copy to clipboard operation
chronic copied to clipboard

Question about next day/current day

Open pikitgb opened this issue 9 years ago • 1 comments
trafficstars

Amazing gem guys ! i really love it.

I have a question about this:

If today is Monday (Oct/3/2016) and i wanna get the next Monday there is anyway to get today has the first Monday available?

Current behavior: Chronic.parse("monday", now: DateTime.current) # it returns => Mon Oct/10/2016

How can it look like. (is this correct ?) Chronic.parse("monday", now: DateTime.current - 1.day) # it returns => Mon Oct/3/2016

Anyway to return by default current day ? is the day match with the first param criteria ?

Best regards.

pikitgb avatar Oct 06 '16 21:10 pikitgb

Chronic is actually missing such feature... There's a parameter context but currently it supports only :past and :future

I've been working on #278 which fixes a lot of issues and it does implement this feature but it's not really ready yet...

with my rewrite branch

date = DateTime.parse('2016-10-03')
Chronic.parse("monday", now: date, context: :past)
=> 2016-09-26 12:00:00 +0300
Chronic.parse("monday", now: date, context: :present)
=> 2016-10-03 12:00:00 +0300
Chronic.parse("monday", now: date, context: :future)
=> 2016-10-10 12:00:00 +0300

davispuh avatar Oct 07 '16 00:10 davispuh