Skip to content

Commit

Permalink
Merge pull request #103 from opentripplanner/dev
Browse files Browse the repository at this point in the history
Bug fix release
  • Loading branch information
evansiroky authored Aug 16, 2019
2 parents ef6aac6 + 9d24ce6 commit 588b349
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/components/narrative/line-itin/transit-leg-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,16 @@ class AlertsBody extends Component {
{this.props.alerts
.sort((a, b) => b.effectiveStartDate - a.effectiveStartDate)
.map((alert, i) => {
const effectiveStartDate = moment(alert.effectiveStartDate)
const daysAway = moment().diff(effectiveStartDate, 'days')
// Add time if alert is effective within one day. Otherwise, use
// calendar long date format (e.g., July 31, 2019).
const dateTimeFormat = Math.abs(daysAway) <= 1
? `${timeFormat}, ${longDateFormat}`
: longDateFormat
const dateTimeString = effectiveStartDate.format(dateTimeFormat)
// If alert is effective as of +/- one day, use today, tomorrow, or
// yesterday with time. Otherwise, use long date format.
const dateTimeString = moment(alert.effectiveStartDate)
.calendar(null, {
sameDay: `${timeFormat}, [Today]`,
nextDay: `${timeFormat}, [Tomorrow]`,
lastDay: `${timeFormat}, [Yesterday]`,
lastWeek: `${longDateFormat}`,
sameElse: `${longDateFormat}`
})
const effectiveDateString = `Effective as of ${dateTimeString}`
return (
<div key={i} className='transit-alert'>
Expand Down

0 comments on commit 588b349

Please sign in to comment.