datetime - Applescript: Convert date into something useful, then perform calculation -
i'm trying create applescript script take date in form:
02/20/99
then, subtract 5 days date, , return date this:
02/15/99
here's basic applescript have, but, obviously, i'm missing logic around converting date can manipulate (and returning readable humans).
set itempath quoted form of posix path of thefile set datestring shell script "awk 'nr == 10 {print $3}' " & itempath & " -" set myduedate datestring - (5 * days) set thetask "pay amex bill" tell application "omnifocus" tell front document set thecontext first flattened context name = "office" set theproject first flattened context name = "bookkeeping - pms" tell theproject make new task properties {name:thetask, context:thecontext, due date:myduedate} end tell end tell
thanks in advance!
i think these lines should sufficient need:
set datestring "02/20/99" set thisdate date datestring set fivedaysearlier thisdate - 5 * days log date string of fivedaysearlier log short date string of fivedaysearlier
this page has more examples of coercions supported when converting strings objects of date class: applescript class reference: date
also, goes without saying, string "02/20/99" not y2k compliant, guesses have made somewhere century date lies in.
Comments
Post a Comment