Skip to content

Instantly share code, notes, and snippets.

@ryoi432
Created December 18, 2015 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryoi432/76979a48587a3ce65d27 to your computer and use it in GitHub Desktop.
Save ryoi432/76979a48587a3ce65d27 to your computer and use it in GitHub Desktop.
matsuya.pl
#!/usr/bin/env perl
use strict;
use warnings;
use Time::Piece;
use Data::ICal;
use Data::Dumper;
# ここにicsファイルのパスを入力
my $ICS_PATH = 'swarm.ics';
my $calendar = Data::ICal->new(filename => $ICS_PATH);
my %stores;
my @hours;
my $entry_num = 0;
for my $entry (@{$calendar->entries})
{
my $locations = $entry->property('location');
my $location = @$locations[0]->value;
if ($location =~ m/松屋/)
{
$entry_num++;
my $dtstarts = $entry->property('dtstart');
my $dtstart = @$dtstarts[0]->value;
my $dt = localtime Time::Piece->strptime($dtstart, "%Y%m%dT%H%M%SZ")->epoch;
print sprintf("%03d", $entry_num) . ". " . $dt->strftime("%Y/%m/%d %H:%M:%S") . " - " . $location . "\n";
$stores{$location} = {
'date' => $dt->strftime("%Y/%m/%d %H:%M:%S"),
'num' => exists($stores{$location}) ? ++$stores{$location}{num} : 1,
};
$hours[$dt->hour]++;
}
}
print "\n";
my $store_num = 0;
for my $store (sort {$stores{$b}{num} <=> $stores{$a}{num} || $stores{$a}{date} cmp $stores{$b}{date}} keys %stores)
{
$store_num++;
print sprintf("%02d", $store_num) . ". " . $stores{$store}{num} . "回 " . $store . " (" . $stores{$store}{date} . ")\n";
}
print "\n";
print Dumper(\@hours);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment