Skip to content

Commit a7ffea4

Browse files
committed
Additional date fix
#1523
1 parent 12c4c0d commit a7ffea4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/util/date.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import moment from 'moment'
55
import _ from 'lodash'
66
import 'moment-duration-format'
7-
import { canChangeDuration } from './phase'
87

98
const HOUR_MS = 60 * 60 * 1000
109
const DAY_MS = 24 * HOUR_MS
@@ -121,12 +120,12 @@ export const getRoundFormattedDuration = (duration) => {
121120
export const convertChallengePhaseFromSecondsToHours = (phases) => {
122121
if (phases) {
123122
_.forEach(phases, (p) => {
124-
if (canChangeDuration(p)) {
125-
p.duration = Math.floor(p.duration / minuteToSecond)
123+
if (p.scheduledStartDate && p.scheduledEndDate) {
124+
const startDate = moment(p.scheduledStartDate).set({ second: 0, millisecond: 0 })
125+
const endDate = moment(p.scheduledEndDate).set({ second: 0, millisecond: 0 })
126+
p.duration = moment.duration(endDate.diff(startDate)).asMinutes()
126127
} else {
127-
// use the same duration display as OR, as long as we aren't changing the fields that should be fine.
128-
const duration = moment.duration(moment(p.scheduledEndDate).diff(moment(p.scheduledStartDate)))
129-
p.duration = Math.ceil(duration.asMinutes())
128+
p.duration = Math.floor(p.duration / minuteToSecond)
130129
}
131130
})
132131
}

0 commit comments

Comments
 (0)