mojombo / chronic

Chronic is a pure Ruby natural language date parser.
http://injekt.github.com/chronic
MIT License
3.23k stars 452 forks source link

Feature to have "previous weekday" as an option. #368

Open TheMeq opened 6 years ago

TheMeq commented 6 years ago

We run reports during the week that use chronic via Spiceworks. We have to manually change the date to the previous weekday as we don't need to run reports for the weekend. Would it be possible to add a weekday option that only include Monday through Friday? Thanks.

davispuh commented 6 years ago

But there already is such option...

 Chronic.parse('last weekday', :guess => false, :context => :past, :now => Time.parse('2017-10-24'))
=> 2017-10-23 00:00:00 +0300..2017-10-24 00:00:00 +0300

Chronic.parse('last weekday', :guess => false, :context => :past, :now => Time.parse('2017-10-23'))
=> 2017-10-20 00:00:00 +0300..2017-10-21 00:00:00 +0300

Chronic.parse('last weekday', :guess => false, :context => :past, :now => Time.parse('2017-10-22'))
=> 2017-10-20 00:00:00 +0300..2017-10-21 00:00:00 +0300

Chronic.parse('last weekday', :guess => false, :context => :past, :now => Time.parse('2017-10-21'))
=> 2017-10-20 00:00:00 +0300..2017-10-21 00:00:00 +0300

Chronic.parse('last weekday', :guess => false, :context => :past, :now => Time.parse('2017-10-20'))
=> 2017-10-19 00:00:00 +0300..2017-10-20 00:00:00 +0300