Skip to content

Commit

Permalink
fix(service-alert): fix date string display in service alert
Browse files Browse the repository at this point in the history
  • Loading branch information
landonreed committed Aug 12, 2019
1 parent 1306196 commit 8afd562
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions lib/components/narrative/line-itin/transit-leg-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,18 +203,14 @@ class AlertsBody extends Component {
.sort((a, b) => b.effectiveStartDate - a.effectiveStartDate)
.map((alert, i) => {
const effectiveStartDate = moment(alert.effectiveStartDate)
let effectiveDateString = 'Effective as of '
const daysAway = moment().diff(effectiveStartDate, 'days')
// Add time if alert is effective within one day.
if (Math.abs(daysAway) <= 1) {
effectiveDateString += `${effectiveStartDate.format(timeFormat)}, `
}
effectiveDateString += effectiveStartDate
.calendar(
null,
{ sameElse: longDateFormat }
)
.split(' at')[0]
// Add time if alert is effective within one day. Otherwise, use
// calendar long date format (e.g., July 31, 2019).
const dateTimeFormatter = Math.abs(daysAway) <= 1
? `${timeFormat}, ${longDateFormat}`
: longDateFormat
const dateTimeString = effectiveStartDate.format(dateTimeFormatter)
const effectiveDateString = `Effective as of ${dateTimeString}`
return (
<div key={i} className='transit-alert'>
<div className='alert-icon'><i className='fa fa-exclamation-triangle' /></div>
Expand Down

0 comments on commit 8afd562

Please sign in to comment.