2 Replies Latest reply: Aug 28, 2012 12:04 AM by stevencarpenter
stevencarpenter Level 1 Level 1 (5 points)

I'm having a big issue with this new forum format (which is awful IMHO) but thats not my problem at hand...

 

My problem is getting the output of an AppleScript to show the correct time in a Lion (+latest patches) new Mail subject line.

 

This is the "Run AppleScript" action (working fine)

on run {input, parameters}

          set FutureDate to (current date) + (6 * days)

          set FutureDate2 to date "11:00:00" of FutureDate

          return FutureDate2

end run

 

This is "View Results" action (output as expected - during testing),

{date "Saturday, 1 September 2012 11:00:00"}

 

The "Set Value of Variable" action (has been set to, without marks),

Variable: <NextSaturday>

 

This is "View Results" Action output (still looking good - during testing),

{date "Saturday, 1 September 2012 11:00:00"}

 

And in the "New Mail Message" action (the rest of email not shown),

Subject = <NextSaturday> @ The Park

 

This should deliver a nice output in the actual new Mail message, however the Subject line time is now incorrectly shown....

Subject = 2012-09-01 10:00:00 +0000 @ The Park

 

I have tried this without the second "View Results" Action (part of fault finding) yet still have the same problem. Sending with the <Current time> Variable works correctly, meaning it probably has something to do with the Date/Time preferences in Lion; located in the UK but on BST at the moment.

 

Maybe I am missing something but after quite a bit of reading this should be possible, but I cannot understand how to overcome this issue.

 

All help gratefully receieved.


MacBook Air, Mac OS X (10.7.4)
  • red_menace Level 6 Level 6 (14,760 points)

    It does look like an issue with coercing an AppleScript date object to an ISO date string - you can just coerce the date to text in your Run AppleScript action.  The way you set the time gives an error on my machine (note that as of AppleScript 2.1, a date string must exactly match one of the system date formats), it should be something like:

     

              set FutureDate to (current date) + (6 * days)

              set time of FutureDate to (11 * hours)

              return FutureDate as text


  • stevencarpenter Level 1 Level 1 (5 points)

    A-ha, a very intriguing response thank you, I like sticking with modifying the same variable, sadly though running under AppleScript (2.2.1) Editor (2.4.3) and Automator (2.2.4) generates the following error using the revised script, which is puzzling considering the attached observation,

     

         error "" number -1721

     

    However by appending the following to the last line in my earlier script,

     

         as text

     

    fixed the initial script and provided the desired output.

     

    Good stuff.