Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

first commit

  • Loading branch information...
commit 30f61abfd18691a9728724e56d0bc781ebf529df 0 parents
Dave Cross authored January 09, 2014

Showing 2 changed files with 85 additions and 0 deletions. Show diff stats Hide diff stats

  1. 40  filmical
  2. 45  films.txt
40  filmical
... ...
@@ -0,0 +1,40 @@
  1
+#!/usr/bin/perl
  2
+
  3
+use strict;
  4
+use warnings;
  5
+use 5.010;
  6
+
  7
+use Data::ICal;
  8
+use Data::ICal::Entry::Event;
  9
+use DateTime::Format::Strptime;
  10
+use Digest::MD5 qw[md5_hex];
  11
+
  12
+open my $film_fh, '<', 'films.txt' or die $!;
  13
+
  14
+my $dt_p = DateTime::Format::Strptime->new(
  15
+  pattern => '%Y-%m-%d'
  16
+);
  17
+my $ical = Data::ICal->new;
  18
+$ical->add_properties(
  19
+  version => '2.0',
  20
+  prodid  => q[Dave's Film iCal Generator],
  21
+);
  22
+
  23
+while (<$film_fh>) {
  24
+  chomp;
  25
+  my ($rel_date, $title) = split /\s+/, $_, 2;
  26
+  my $entry = Data::ICal::Entry::Event->new;
  27
+  my $date  = $dt_p->parse_datetime($rel_date);
  28
+  my $start = $date->strftime('%Y%m%d');
  29
+  my $end   = $date->add(days => 1)->strftime('%Y%m%d');
  30
+  my $uid   = "$date-" . md5_hex($title) . '@dave.org.uk';
  31
+  $entry->add_properties(
  32
+    summary => $title,
  33
+    uid     => $uid,
  34
+    dtstart => [ $start, { VALUE => 'DATE' } ],
  35
+    dtend   => [ $end,   { VALUE => 'DATE' } ],
  36
+  );
  37
+  $ical->add_entry($entry);
  38
+}
  39
+
  40
+print $ical->as_string;
45  films.txt
... ...
@@ -0,0 +1,45 @@
  1
+2014-01-01 American Hustle
  2
+2014-01-03 Age of Uprising
  3
+2014-01-03 Last Vegas
  4
+2014-01-03 The Missing Picture
  5
+2014-01-10 12 Years a Slave
  6
+2014-01-10 After Tiller
  7
+2014-01-10 Delivery Man
  8
+2014-01-10 Kiss the Water
  9
+2014-01-10 The Railway Man
  10
+2014-01-17 The Wolf of Wall Street
  11
+2014-01-24 August: Osage County
  12
+2014-01-24 Dark Days
  13
+2014-01-24 Grudge Match
  14
+2014-01-24 Inside Llewyn Davies
  15
+2014-01-24 Teenage
  16
+2014-01-31 Journal de France
  17
+2014-01-31 The Armstrong Lie
  18
+2014-02-07 Robocop
  19
+2014-02-14 The Monuments Men
  20
+2014-02-21 A New York Winter's Tale
  21
+2014-03-07 300: Rise of an Empire
  22
+2014-03-07 A Long Way Down
  23
+2014-03-07 Nymphomaniac
  24
+2014-03-07 The Grand Budapest Hotel
  25
+2014-03-28 Captain America: The Winter Soldier
  26
+2014-03-28 Muppets Most Wanted
  27
+2014-04-04 Before I Go to Sleep
  28
+2014-04-04 Divergent
  29
+2014-04-18 The Amazing Spider-Man 2
  30
+2014-05-16 Godzilla
  31
+2014-05-22 X-Men: Days of Future Past
  32
+2014-05-30 Maleficent
  33
+2014-06-06 A Million Ways to Die in the West
  34
+2014-07-04 How to Train Your Dragon 2
  35
+2014-07-17 Dawn of the Planet of the Apes
  36
+2014-07-25 Jupiter Ascending
  37
+2014-08-01 Guardians of the Galaxy
  38
+2014-08-29 Sin City: A Dame to Kill For
  39
+2014-10-03 Gone Girl
  40
+2014-10-17 The Judge
  41
+2014-10-24 Fury
  42
+2014-11-07 Interstellar
  43
+2014-11-21 The Hunger Games: Mockingjay - Part 1
  44
+2014-12-12 Exodus
  45
+2014-12-19 The Hobbit: There and Back Again

0 notes on commit 30f61ab

Please sign in to comment.
Something went wrong with that request. Please try again.