File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 4
4
import moment from 'moment'
5
5
import _ from 'lodash'
6
6
import 'moment-duration-format'
7
- import { canChangeDuration } from './phase'
8
7
9
8
const HOUR_MS = 60 * 60 * 1000
10
9
const DAY_MS = 24 * HOUR_MS
@@ -121,12 +120,12 @@ export const getRoundFormattedDuration = (duration) => {
121
120
export const convertChallengePhaseFromSecondsToHours = ( phases ) => {
122
121
if ( phases ) {
123
122
_ . 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 ( )
126
127
} 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 )
130
129
}
131
130
} )
132
131
}
You can’t perform that action at this time.
0 commit comments