• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: a date IS a date?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: a date IS a date?


  • Subject: Re: a date IS a date?
  • From: Ed Stockly <email@hidden>
  • Date: Sat, 9 Feb 2008 08:00:59 -0800

Dates are dates, even in iTunes, so no need to hate appleScript.

But a year may not be a year in iTunes...

>>>I needed almost half an hour before I found a working solution but still don't know:
>>>a) Why I need this construct

There is a terminology conflict with iTunes that prevents it from working with some parts of AppleScript dates as expected

>>"year of x" works
>>"year of y" fails

Nope, you didn't test "year of x" inside the iTunes tell, or "year of y" outside the iTunes tell

Try this:

set x to current date
display dialog (month of x)  
display dialog (day of x)  
display dialog (weekday of x)  
display dialog (year of x)  
display dialog (date string of x)  
display dialog (short date string of x)  
display dialog (time string of x)  
display dialog (time of x)  
display dialog (year of x)  

tell application "iTunes"
  display dialog (month of x)  
  display dialog (day of x)  
  display dialog (weekday of x)  
  display dialog (date string of x)  
  display dialog (short date string of x)  
  display dialog (time string of x)  
  display dialog (time of x)  
  display dialog (year of x)  
end tell

iTunes uses the keywords year and time for its own purposes.

They're both properties of tracks and used elsewhere in the app, so, this is a terminology conflict.

Using a nested System events tell sent the command to another app without the conflict, so that worked.

>>b) How one should have known

Trial and error, but, take a scientific approach in your debugging. Simplify and reduce the number of variables and simplify each command.

For example, had you tried year of x inside and outside the tell block that would have told you that it was in iTunes with any date, not just dates generated by the application.

Also, the command
  display dialog (year of x) 

is a compound command and could be simplified to speed debugging.

set xYear to year of x
set xYear to xYear as string
display dialog xYear

 This would have told you that:

year of x

would also fail inside an iTunes tell.

HTH,

ES


=
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: a date is not a date? Or: Why I sometimes hate AppleScript...
  • Next by Date: Re: a date is not a date? Or: Why I sometimes hate AppleScript...
  • Previous by thread: Re: a date is not a date? Or: Why I sometimes hate AppleScript...
  • Next by thread: Re: A date IS a date
  • Index(es):
    • Date
    • Thread