aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand/Bromley.pm
diff options
context:
space:
mode:
authorM Somerville <matthew-github@dracos.co.uk>2020-11-04 13:45:20 +0000
committerM Somerville <matthew-github@dracos.co.uk>2020-11-11 10:37:44 +0000
commit5e2f1b3509391f891955db8b8fe05dbf40b7a041 (patch)
tree8bc4f1fd87a12e8191ee8b80df87f5d5ecc146c1 /perllib/FixMyStreet/Cobrand/Bromley.pm
parent3f70d1f0b4d543072eda2d1b59092a5b9e6b3253 (diff)
[Bromley] Adapt if last instance is in future.
Diffstat (limited to 'perllib/FixMyStreet/Cobrand/Bromley.pm')
-rw-r--r--perllib/FixMyStreet/Cobrand/Bromley.pm13
1 files changed, 12 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Bromley.pm b/perllib/FixMyStreet/Cobrand/Bromley.pm
index f80bdaa12..fc41eae28 100644
--- a/perllib/FixMyStreet/Cobrand/Bromley.pm
+++ b/perllib/FixMyStreet/Cobrand/Bromley.pm
@@ -695,10 +695,21 @@ sub _parse_schedules {
my $last = $schedule->{LastInstance};
$d = construct_bin_date($last->{CurrentScheduledDate});
- if ($d && (!$max_last || $d > $max_last->{date})) {
+ # It is possible the last instance for this schedule has been rescheduled to
+ # be in the future. If so, we should treat it like it is a next instance.
+ if ($d && $d->strftime("%F") gt $today && (!$min_next || $d < $min_next->{date})) {
+ my $last_changed = $last->{CurrentScheduledDate}{DateTime} ne $last->{OriginalScheduledDate}{DateTime};
+ $min_next = {
+ date => $d,
+ ordinal => ordinal($d->day),
+ changed => $last_changed,
+ };
+ } elsif ($d && (!$max_last || $d > $max_last->{date})) {
+ my $last_changed = $last->{CurrentScheduledDate}{DateTime} ne $last->{OriginalScheduledDate}{DateTime};
$max_last = {
date => $d,
ordinal => ordinal($d->day),
+ changed => $last_changed,
ref => $last->{Ref}{Value}{anyType},
};
}