Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Perl / June 2005



Tip: Looking for answers? Try searching our database.

Mac::Glue, g_t, and dates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ricardo SIGNES - 14 Jun 2005 12:57 GMT
I can do this in AppleScript:

    tell application "iTunes"
        tell playlist "Library"
            get tracks whose played date is greater than date "January 1, 2005"
        end tell
    end tell

I can't reproduce this kind of query in Mac::Glue, as far as I can tell.
I tried using a string and a timestamp in place of the date, but to no
avail.  What should I be doing?

Signature

rjbs

Chris Nandor - 14 Jun 2005 16:16 GMT
> I can do this in AppleScript:
>
[quoted text clipped - 8 lines]
> I tried using a string and a timestamp in place of the date, but to no
> avail.  What should I be doing?

Not sure what you tried, but basically, you use track whose(played_date =>
g_t => $date).  The question is how to construct $date.  AppleScript can
afford to make more assumptions than we can, so param_type() helps us
defined types when necessary.

For dates there's two steps: get the epoch time (with timelocal here), and
then pass it to param_type to define it as typeLongDateTime.

use Mac::Glue ':all';
use Time::Local;

my $itunes = new Mac::Glue 'iTunes';
my $library = $itunes->obj(playlist => 'Local Library');

my $time = timelocal(0, 0, 0, 1,  0, 105);  # jan 1 2005

my @tracks = $library->obj(track =>
  whose(played_date => g_t => param_type(typeLongDateTime, $time)),
)->get;

# check our work
for (@tracks) {
  print $_->prop('name')->get, ": ";
  print scalar localtime $_->prop('played date')->get, "\n";
}

Signature

Chris Nandor                      pudge@pobox.com    http://pudge.net/
Open Source Technology Group       pudge@ostg.com     http://ostg.com/

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.