Automatically detect date format and require a date

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I've got an issue where I want to find the first date in a document and the format can vary a lot.
So I use `content contain match` with a date and use the default which searches for "any" date format.

This works fine most of the time but I've got a few files where it always matches the current date.
I found the issue to be that there was a `9:00-15:00` before the correct date. It seems that Hazel matches the `9:00` as a date and according to the documentation it uses the current date as default. When testing the rule the date was `today 9:00`.

I'd love to have two additional checkboxes when `Automatically detect date format` is selected. `Require date` and `Require time`. By default both would be off which is the current behavior.
With `Require date` it would match `1.1.23` and `1.1.23 9:00` but not `9:00` since there is no date but only a time.
With `Require time` it would match `9:00` and `1.1.23 9:00` but not `1.1.23` since there is no time but only a date.
With both options it would match `1.1.23 9:00` but not `1.1.23` or `9:00` since there is only either time or date.
jandamm
 
Posts: 8
Joined: Sun Feb 18, 2018 10:46 am

Thanks for the suggestion. Unfortunately, the automatic date detection is based on Apple's data detector system which doesn't allow ways to specify that. I've submitted bug reports for improvements but of course, nothing has been done about it. For this to change, I would probably have to implement my own date detector.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks for the reply.
I didn't know that the matcher comes from Apple.
I think it'd be a nice feature but reimplementing the matcher with all its date quirks and localization isn't easy.
jandamm
 
Posts: 8
Joined: Sun Feb 18, 2018 10:46 am


Return to Support