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 44import moment from 'moment'
55import _ from 'lodash'
66import 'moment-duration-format'
7- import { canChangeDuration } from './phase'
87
98const HOUR_MS = 60 * 60 * 1000
109const DAY_MS = 24 * HOUR_MS
@@ -121,12 +120,12 @@ export const getRoundFormattedDuration = (duration) => {
121120export 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 }
You can’t perform that action at this time.
0 commit comments