diff options
author | Christian Pointner <equinox@spreadspace.org> | 2016-04-22 19:15:35 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2016-04-22 19:15:35 (GMT) |
commit | 57d18e373f2c3bbe55b206c3c8263057a26b7505 (patch) | |
tree | f18b96876b3a64df1c1be2d8588692252fbd11f5 /utils | |
parent | fe577062f4ff680652641da01e02b6164b5c9571 (diff) |
improved date handling
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/rhrd-schedules | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/utils/rhrd-schedules b/utils/rhrd-schedules index a1e2d2f..fd74380 100755 --- a/utils/rhrd-schedules +++ b/utils/rhrd-schedules @@ -60,18 +60,18 @@ sub generate sub show__day { - my ($ctx, @date) = @_; + my ($ctx, $year, $month, $day) = @_; - print "https://pv.helsinki.at/export/day_schedule/$date[0]/$date[1]/$date[2]\n"; + print "https://pv.helsinki.at/export/day_schedule/$year/$month/$day\n"; - my ($ret, $data) = RHRD::utils::fetch_parse_json("https://pv.helsinki.at/export/day_schedule/$date[0]/$date[1]/$date[2]", "rhrd-schedules"); + my ($ret, $data) = RHRD::utils::fetch_parse_json("https://pv.helsinki.at/export/day_schedule/$year/$month/$day", "rhrd-schedules"); if(!$ret) { print STDERR "Error fetching export from PV: $data\n"; return 1; } - my $dow = Date::Calc::Day_of_Week(@date); - my $week = RHRD::utils::get_rd_week(DateTime->new(year => $date[0], month => $date[1], day => $date[2], hour => 12)); + my $dow = Date::Calc::Day_of_Week($year, $month, $day); + my $week = RHRD::utils::get_rd_week(DateTime->new(year => $year, month => $month, day => $day, hour => 12)); my $errcnt = 0; for my $entry (@{$data}) { @@ -125,14 +125,19 @@ sub show { my ($ctx, $week, $dow) = @_; - # TODO: parse week number and day - - my @date = (2016, 4, 14); + my @dates = (); -# print "$date[0].$date[1].$date[2] (" . Date::Calc::Day_of_Week_to_Text() . "):\n"; - print Date::Calc::Date_to_Text(@date) . ":\n"; - my $errcnt = show__day($ctx, @date); - print " -> $errcnt errors.\n\n"; + # TODO: parse week number and day + my @d1 = (2016, 4, 14); + my @d2 = (2016, 4, 15); + $dates[0] = \@d1; + $dates[1] = \@d2; + + for my $date (@dates) { + print Date::Calc::Date_to_Text(@{$date}) . ":\n"; + my $errcnt = show__day($ctx, @{$date}); + print " -> $errcnt errors.\n\n"; + } return 0; } |