argenos / nldates-obsidian

Work with dates in natural language in Obsidian
MIT License
497 stars 46 forks source link

FR: Support `15th` format #73

Closed SkepticMystic closed 2 years ago

SkepticMystic commented 2 years ago

Hey :)

It'd be awesome if I could type @@15th and have it resolve as 2021-12-15. Ambiguity arises if the date given has already passed. For @@2nd, should it be the 2nd of December (already passed), or 2nd Jan (still to come). Perhaps this could be a setting? I personally would always want it to find the 2nd still to come

argenos commented 2 years ago

I think this should work if you do "mid December"

argenos commented 2 years ago

For the 2nd case, someone recently asked about this in https://github.com/argenos/nldates-obsidian/discussions/70, but I can't understand the use case clearly, and it seems to me it would open a lot of edge cases, i.e. which reference date to use as a "start" when we try to parse dates. Can you or @Gnopps maybe mention in which contexts the dates should always refer to the future?

Gnopps commented 2 years ago

In my case I more often reference future dates than past dates, for example:

argenos commented 2 years ago

Sorry, this is still vague enough that "often" means you still reference something in the present (this Tuesday vs next Tuesday) or the past (last Tuesday). If I set the reference to the "future", to get a date for this Tuesday you'd have to parse "last Tuesday", and the Tuesday from last week would have to be referenced by date e.g. Nov 30th. Does that make sense to you?

Gnopps commented 2 years ago

I understand you. I pretty rarely reference back dates, almost always future dates. So I'd prefer any generic "tue" will be interpreted as "next tue". Your suggestion looks good.

The chrono-lirbary supports this setting with "forwardDate", so couldn't that be a plugin setting if that should be enabled or not?

argenos commented 2 years ago

The point is that this is the way you use it, but other people don't. Making this a setting still introduces a lot of edge cases (like the ones above, even if you might not run into them).

You can use how we use forwardDate here: https://github.com/argenos/nldates-obsidian/blob/master/src/parser.ts#L67

liamcain commented 2 years ago

fwiw, I actually found myself trying to use @2nd recently and was a bit disappointed to see [[invalid date]]. Since moment JS can parse date ordinals (1st, 2nd, 3rd), I think this should be easy to add.