Skip to content

Commit 42ea33d

Browse files
ryehawkrives
authored andcommitted
parseTime: Guard against open times far in the future
Similar to #3376, this commit prevents an open time from showing up more than six months in the future, by subtracting a year from any that are more than 6 months ahead of the provided context moment. [GitHub] This commit resolves #3375, again. Signed-off-by: Kristofer Rye <[email protected]> Tested-by: Kristofer Rye <[email protected]>
1 parent 990fe65 commit 42ea33d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

source/views/transportation/bus/lib/parse-time.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ export const parseTime = (now: moment) => (
2121
m.dayOfYear(now.dayOfYear())
2222

2323
let sixMonthsAgo = moment(now).subtract(6, 'months')
24+
let sixMonthsFromNow = moment(now).add(6, 'months')
2425

2526
if (m.isBefore(sixMonthsAgo)) {
2627
m.add(1, 'year')
28+
} else if (m.isAfter(sixMonthsFromNow)) {
29+
m.subtract(1, 'year')
2730
}
2831

2932
return m

0 commit comments

Comments
 (0)