Nils
February 11, 2023, 6:42am
1
I am looking for date parsing in shortcuts.
String in, date out.
Has anyone done this yet?
I want to parse strings like
“10d before last Friday of April”
I don’t mind the syntax, only the expressivity. So something like this would be perfectly fine
addDaysTo(dayOfMonth(nextMonth("April"), "last Friday"),-10)
Or maybe as json which is more parsing friendly in shortcuts
{"type": "operation",
"operation": "add",
"date": {
"type": "operation",
"operation": "dayOf",
"qualifier": "last friday",
"dateRange": {
"type": "operation",
"operation": "next",
"direction": "forward",
"value": "April"},
"difference": {"type": "days", "value": -10}}
Would need to rethink that type system though
tf2
February 11, 2023, 12:40pm
2
I don’t use Shortcuts a lot, but I was impressed to discover a while ago that the Get Dates From Text action does a lot of this kind of thing out of the box. It may take a little fiddling to get the right approach, however. (Exits: typos)
See this thread from a little while back: Time Based Shortcut
Nils
February 11, 2023, 8:34pm
3
Thank you for the pointers!
Shortcuts natural language syntax is described here and is ok, but does not support date math.
The toolbox pro action does a bit more but still less than what I am used to of Things’s in-app natural language syntax. Hmmmm.
Still good to look at some examples!
So still searching … Maybe I just start a simple shortcut for date parsing and see if I can frame my needs simple enough so that I get it working.