From df6361bfd39f624e34d1579cea1944d285ee9f0b Mon Sep 17 00:00:00 2001 From: Gianni Ceccarelli Date: Tue, 14 May 2013 15:41:49 +0100 Subject: allow limiting calc interval --- calc-price | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/calc-price b/calc-price index be33ac0..4ae2aa5 100644 --- a/calc-price +++ b/calc-price @@ -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); -- cgit v1.2.3