Skip to content

Commit

Permalink
fix(utils/viewer): Format time with timezone suffix.
Browse files Browse the repository at this point in the history
  • Loading branch information
binh-dam-ibigroup committed Dec 22, 2020
1 parent edd5a4b commit 8ebacce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/components/viewers/stop-schedule-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const TimeCell = styled.td`
text-align: right;
white-space: nowrap;
`
const TimeHeader = styled.th`
text-align: right;
`

/**
* Table showing scheduled departure times for the specified stop organized
Expand Down Expand Up @@ -85,7 +88,7 @@ class StopScheduleTable extends Component {
<th>Block</th>
<th>Route</th>
<th>To</th>
<th>Departure</th>
<TimeHeader>Departure</TimeHeader>
</tr>
</thead>
<tbody>
Expand Down
10 changes: 8 additions & 2 deletions lib/util/viewer.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import moment from 'moment'
import 'moment-timezone'
import coreUtils from '@opentripplanner/core-utils'
import React from 'react'

import { isBlank } from './ui'

const {
formatDuration,
formatSecondsAfterMidnight,
getUserTimezone
} = coreUtils.time

Expand Down Expand Up @@ -221,5 +222,10 @@ export function formatDepartureTime (departureTime, timeFormat, homeTimezone) {
const inHomeTimezone = homeTimezone && homeTimezone === userTimeZone
const format = inHomeTimezone ? timeFormat : `${timeFormat} z`

return formatSecondsAfterMidnight(departureTime, format)
// FIXME: fix OTP-UI's formatSecondsAfterMidnight method per below.
return moment()
.tz(homeTimezone)
.startOf('day')
.seconds(departureTime)
.format(format)
}

0 comments on commit 8ebacce

Please sign in to comment.