Bruins Schedule iCal Script

| | Comments (0)
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,EndT ime,Alldayevent,Reminderonoff,ReminderDate,Reminde rTime,Description,Location,Priority,Private,Sensit ivity,Showtimeas
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

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on October 13, 2005 9:15 AM.

Straw Men was the previous entry in this site.

Mac-Apps-Launch-1.92 Released is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.