Method and source check
Last checked:
Automated source and implementation review, including worked examples and documented numerical limits. This review does not provide professional advice or specialist approval.
Method
For decimal input, round hours × 60 to a whole minute, then divide by 60 for hours and remainder minutes. For clock input, compute hours + minutes ÷ 60.
total minutes = round(decimal hours × 60)
decimal hours = hours + minutes / 60
hours = floor(total minutes/60); minutes = total minutes mod 60
Variables and units
- decimal hours
- nonnegative hours
- minutes
- whole minutes, 0–59 for time input
Worked example
1.5 hours = 1 hour 30 minutes; 1.999 hours rounds to 2 hours 0 minutes.
Limitations
Decimal-to-clock mode rounds total minutes once to the nearest whole minute, carrying 60 to the next hour. Decimal-hour display rounds to two decimals.
- Decimal input rounds to a whole minute; displayed decimal hours round to hundredths. Payroll and billing policies may require different rounding.
- Clock input requires safe whole hours and minutes; rounded total minutes must be at most 9,007,199,254,740,991. Unsupported durations are rejected on a visible input field.
- 1.5 hours → 1h30m
- 1h30m → 1.50 hours
- 1.999 hours → 2h00m after minute carry
- 1.5 decimal hours → 90 total minutes; 1.999 decimal hours → 120 total minutes after rounding and carry.
- 1e308 decimal hours and fractional clock hours are rejected; clock minutes must be whole numbers from 0 through 59.