aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Cobrand/Bromley.pm
diff options
context:
space:
mode:
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},
};
}