Skip to content

Instantly share code, notes, and snippets.

@lopnor lopnor/
Created May 16, 2012

What would you like to do?
use strict;
use warnings;
use Net::Google::Calendar;
use Config::Pit;
use DateTime;
use Email::MIME;
use Data::Dumper;
use HTTP::Date ();
use FindBin;
my $mail = Email::MIME->new(do {local $/; <>});
my $body = substr($mail->body, -1024);
my $title = $mail->header('Subject');
my $start = DateTime->from_epoch(
epoch => HTTP::Date::str2time($mail->header('Date')),
time_zone => 'local',
my ($received) = $mail->header('Received');
my $end = DateTime->from_epoch(
epoch => HTTP::Date::str2time([split(';', $received)]->[-1]),
time_zone => 'local',
my $config = do "$FindBin::Bin/" or die;
my $calendar_title = 'cron logs';
if ($body !~ m{All tasks finished successfully!!! :\)}) {
$calendar_title .= ' fail'
my $client = Net::Google::Calendar->new;
$client->login(@$config{qw(username password)});
my @cals = $client->get_calendars;
if (my ($cal) = grep {$_->title eq $calendar_title} @cals) {
} else {
die "calendar $calendar_title not found";
my $entry = Net::Google::Calendar::Entry->new;
$entry->when($start, $end);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.