diff options
author | Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com> | 2013-05-14 15:41:49 +0100 |
---|---|---|
committer | Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com> | 2013-05-14 15:41:49 +0100 |
commit | df6361bfd39f624e34d1579cea1944d285ee9f0b (patch) | |
tree | a49e1f5e609adf9499047410977c054d2b7fccc7 | |
parent | more stations for calc-price (diff) | |
download | oyster-df6361bfd39f624e34d1579cea1944d285ee9f0b.tar.gz oyster-df6361bfd39f624e34d1579cea1944d285ee9f0b.tar.bz2 oyster-df6361bfd39f624e34d1579cea1944d285ee9f0b.zip |
allow limiting calc interval
-rw-r--r-- | calc-price | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -use 5.016; +use 5.014; use DBI; use Path::Class; use Getopt::Long::Descriptive; @@ -175,12 +175,23 @@ sub update_range { return; } +my $start_from; +if ($ARGV[0]) { + require DateTime::Format::Natural; + $start_from = DateTime::Format::Natural->new( + prefer_future => 0, + time_zone=>'Europe/London', + )->parse_datetime($ARGV[0])->truncate(to=>'day'); +} + while (my $row=$sth->fetchrow_hashref) { my $start_ts = DateTime->from_epoch( epoch=> $row->{start_ts}, time_zone=>'Europe/London', ); + next if $start_from && $start_ts < $start_from; + my $day_key= day_of_journey($start_ts)->ymd; my @journey;my ($peak,$tube,$start_zone,$stop_zone)=(0,0,0,0); |