Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

pudge (1)

  (email not shown publicly)
AOL IM: Crimethnk (Add Buddy, Send Message)

I run this joint, see?

Journal of pudge (1)

Thursday October 13, 2005
11:15 AM

Bruins Schedule iCal Script

[ #27150 ]

I fetched the CSV version of the Boston Bruins schedule, and then wrote this script to import it into iCal using Mac::Glue. Hooray.

Update: The CSV file has incorrect dates for when the time is past midnight, so it has games going from 10 p.m. on the 4th to 1 a.m. on the 4th. Oops. Also added quick DST calculation.

### first make empty "Bruins" calendar in iCal!
use strict;
use warnings;
use Date::Parse;
use Mac::Glue ':all';
my $ical = new Mac::Glue 'iCal';
my $bcal = $ical->obj(calendar => whose(title => equals => 'Bruins'));
my $bloc = location(end => $bcal);
my($dsts) = str2time('April 2 2006');
my($dste) = str2time('October 30 2005');
while (<DATA>) {
    next unless m{^(Boston Bruins (at|vs\.) ([^,]+)),((\d+)/(\d+)/(\d+),(\d+):(\d+):00 ([AP]M)),((\d+)/(\d+)/(\d+),(\d+):(\d+):00 ([AP]M)),};
    my($summ, $start, $end) = ($1, $4, $11);
    $start = str2time($start);
    $end   = str2time($end);
    $end += 86400 if $start > $end;
    my $adj = 3600 * ( ($start < $dsts && $start > $dste) ? 4 : 3 );
    $_ -= $adj for ($start, $end);
#    printf "%d : %s : %s : %s\n", $adj, $summ, scalar(localtime $start), scalar(localtime $end);
#    next;
        new => 'event',
        at  => $bloc,
        with_properties => {
            summary    => $summ,
            start_date => $start,
            end_date   => $end,
#Subject,StartDate,StartTime,EndDate,EndTime,Alldayevent,Reminderonoff, ReminderDate,ReminderTime,Description,Location,Priority,Private,Sensitivity,Show timeas
Boston Bruins vs. Montreal,10/5/2005,7:00:00 PM,10/5/2005,10:00:00 PM,FALSE,TRUE,10/5/2005,12:00:00 PM,,TD Banknorth Garden,Normal,TRUE,Normal,0
Boston Bruins at Buffalo,10/7/2005,8:00:00 PM,10/7/2005,11:00:00 PM,FALSE,TRUE,10/7/2005,4:00:00 PM,,Away,Normal,TRUE,Normal,0

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.