Date Comparison - Suggestions Welcome
I’m working on the date comparison functions at the moment, but I’d like to get some feedback before proceeding.
By default, the filter will use strtotime() to turn the user entered date into a timestamp, so more natural expressions can be entered. A different function can be provided in config.
I’m considering the following patterns:
date - The exact date
date1 to date2 - Between date1 and date2 inclusive
< date - Before the specified date
<= date - On or before the specified date
>= date - On or after the specified date
> date - After the specified date
So, for example, you could enter the following filters:
today - Date is today’s
>= yesterday - Date is yesterday’s or later
> 4th Jan - Date is after 4th Jan this year.
today to today + 7 days - Between today and seven days after today.
Or to prevent any ambiguity:
< 2015-01-25 - before 25th Jan 2015.
Very English-centric - PHP’s strtotime can only process English date expressions. The implementer can, however, change the function that is used.
Natural syntax may cause confusion - if people can enter "today" and other natural language expressions, they might think they can enter "Jan 2014" or "in Jan 2014" or "during Jan 2014" to find any records in January. The first will actually be processed as January 1st and the other two will not be treated as dates at all.
I’d welcome any suggestions. I don’t want to make the system too confusing.