September 12, 2020 at 9:08 AM by Dr. Drang
I don’t want to keep talking about dates in Shortcuts, but I keep learning new things.
Yesterday, I said
As for the Shortcuts bug, it’s something I should have found in testing right away. Although the Ask for Input step at the top of the shortcut allows me to choose a date other than the default of the current date, the event that gets added to my calendar is always three weeks after the current date. No matter what I change the date to in the picker. Kind of makes the picker pointless.
This was wrong. There is no bug in the date picker. The source of the problem was a date parsing error later in the shortcut.
This morning, I was thinking about this “bug” and decided it didn’t make any sense. If the date picker didn’t work, surely there’d have been an outcry long ago; I wouldn’t be the first to run across it. So I started testing.
Here’s the simple testing shortcut:
I started out setting the custom date format of
Provided Input in Step 2 to the format Tony suggested:
yyyy MM dd 21:00:00.
When the date picker came up, I set it to September 10.
And the alert popped up with the time I wanted, 9:00 PM, but the date set to September 17—five days from today, not five days from the date I chose in the picker.
Adding hyphens to the custom date format,
fixed the problem. That weird format Europeans like,
dd MMM yyyy 21:00:00
also worked. Both of them gave a result of “Sep 15, 2020 at 9:00 PM” when I chose September 10 in the picker.
While I understand that there are limits to what Shortcuts can parse, I don’t understand the reversion to the current date when the parsing fails. By the time we get to the second step, Shortcuts should already know that I’ve chosen September 10 in the picker. But whatever the reason, the upshot is this: If you’re going to use a custom format to adjust a date or time, use the simplest format you can for the part that isn’t getting adjusted.