Skip to content

Commit 8558ab1

Browse files
committed
fix(display): affichage des temps en heures
1 parent 96f32d8 commit 8558ab1

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

js/script.js

+15-4
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ function calculate() {
138138
calculateSimpleDive(dictionary.Sd, inputDepth2.value, inputDuration2.value)
139139
return
140140
}
141-
addVariable(`${dictionary.Rif} ${inputInterval.value} ${dictionary.minutes}`, refInterval, `${dictionary.min}`)
141+
addVariable(`${dictionary.Rif} ${minToHour(inputInterval.value)}`, minToHour(refInterval))
142142

143143
const nitCoef = Mn90Cr[firstDiveStop[5]][refIntervalPos]
144144
const refCoefPos = posNext(nitCoef, TbCoeff)
@@ -151,13 +151,13 @@ function calculate() {
151151
addVariable(`${dictionary.Rdf} ${inputDepth2.value} ${dictionary.meters}`, refDepth2, `${dictionary.m}`)
152152

153153
const increase = Majo[refDepth2][refCoefPos]
154-
addVariable(`${dictionary.Sdi}`, increase, `${dictionary.min}`)
154+
addVariable(`${dictionary.Sdi}`, minToHour(increase))
155155

156156
const increasedDuration = Number(inputDuration2.value) + increase
157157
const refDuration2 = next(increasedDuration, Mn90T[refDepth2])
158158
if (!refDuration2)
159159
throw new Error(`<div>${dictionary.Tdtdneitt.replace(':1:', increasedDuration).replace(':2:', refDepth2)}</div>`)
160-
addVariable(`${dictionary.Rduf} ${increasedDuration} ${dictionary.minutes}`, refDuration2, `${dictionary.min}`)
160+
addVariable(`${dictionary.Rduf} ${minToHour(increasedDuration)}`, minToHour(refDuration2))
161161
let secondDiveStop = Mn90P[refDepth2 +""+ refDuration2]
162162

163163
results.innerHTML += `<div><h3>${dictionary.Sd}</h3>
@@ -177,7 +177,7 @@ function calculateSimpleDive(label, inputDepth, inputDuration) {
177177
const refDuration = next(inputDuration, Mn90T[refDepth])
178178
if (!refDuration)
179179
throw new Error(`<div>${dictionary.Tdtdneitt.replace(':1:', inputDuration).replace(':2:', refDepth)}</div>`)
180-
addVariable(`${dictionary.Rduf} ${inputDuration} ${dictionary.minutes}`, refDuration, `${dictionary.min}`)
180+
addVariable(`${dictionary.Rduf} ${minToHour(inputDuration)}`, minToHour(refDuration))
181181

182182
const diveStop = Mn90P[refDepth +""+ refDuration]
183183
addVariable(`${dictionary.GPSfxmitxmt.replace(':1:', refDuration).replace(':2:', refDepth)}`, diveStop[5])
@@ -261,3 +261,14 @@ function handleShare(e) {
261261
}, 1500)
262262
})
263263
}
264+
265+
function minToHour(value) {
266+
const hours = Math.floor(value / 60)
267+
const minutes = value % 60
268+
if (hours === 0)
269+
return `${value} ${dictionary.min}`
270+
if (minutes === 0)
271+
return `${hours}h`
272+
273+
return `${Math.floor(value / 60)}h${value % 60}`
274+
}

0 commit comments

Comments
 (0)