bear / parsedatetime

Parse human-readable date/time strings
Apache License 2.0
694 stars 105 forks source link

Interpreting backwards instead of forwards #240

Open jrw35 opened 4 years ago

jrw35 commented 4 years ago

Hi. At the moment I think parsedatetime always interprets a string like "Friday" as meaning "next Friday". Is it possible to choose to make the default be the opposite? So "Friday" on its own would mean "last Friday".

Thanks very much. This is an incredibly useful project.

bear commented 4 years ago

@jrw35 apologies for the slow response...

You can control that by passing to the Calendar() object when creating it a custom Constant() object that has the DOWParseStyle set

See the source https://github.com/bear/parsedatetime/blob/master/parsedatetime/__init__.py#L2352 for what the value to set it is