Page 1 of 1

Sending Date Only to Fantastical 2

PostPosted: Tue Apr 11, 2017 7:28 pm
by SpinalTap
Hello,

I am trying to process a credit card bill by renaming it, pulling out the due date and sending that date to Fantastical 2.

I am getting the due date using the following "Contents contain match" - Dec 31, 1999. By doing this match, I am successful at matching the due date on the bill.

In my "Do" list, I am running the following embedded AppleScript and passing in Due Date as an inputAttribute:

set a to "Mastercard Due "
set b to item 1 of inputAttributes
set c to " reminder 5 days before in calendar Calendar"
set d to a & b & c

tell application "Fantastical 2"
parse sentence d with add immediately
end tell


This works successfully, but it sends the following to Fantastical 2:

Mastercard Due Monday, May 1, 2017 at 5:19:32 PM reminder 5 days before in calendar Calendar

As you can see it is sending what happens to be the current time with it (in red above). Is there anyway to parse out just the date from the inputAttributes so that I can concatenate my own time to the statement?

Thanks in advance.

Re: Sending Date Only to Fantastical 2

PostPosted: Wed Apr 12, 2017 11:27 am
by Mr_Noodle
Dates always contain a time component. You'll need to search around for how to change the date format in AppleScript such that the time part is masked out.

If you are only using the date for textual purposes, then an alternative would be to use a custom text attribute instead of a date one. That way, you just grab the raw text and pass that to the script.

Re: Sending Date Only to Fantastical 2

PostPosted: Wed Apr 12, 2017 5:59 pm
by SpinalTap
Thanks Mr_Noodle, that pointed me in the right direction. The following AppleScript works now.

set str1 to "Mastercard Payment Due "
set due_date to item 1 of inputAttributes
set {year:y, month:m, day:d} to due_date
set str2 to " remind 5 days before in calendar Calendar"
set dateString to m & " " & d & ", " & y & " "
set str3 to str1 & dateString & str2

tell application "Fantastical 2"
parse sentence str3 with add immediately
end tell

I appreciate your help.

Thanks,

-Dean