Extract Total Minutes
Extract Total Minutes — Chronos Documentation.
getTotalMinutes
Converts a time string in HH:MM or -HH:MM format into total minutes from 00:00.
Import
import { getTotalMinutes } from "toolbox-x/utils";Function Signature
getTotalMinutes(time: `-${ClockTime}` | ClockTime): number;Parameters
time: A time string in either:- Positive format:
HH:MM(e.g.,"08:30") - Negative format:
-HH:MM(e.g.,"-05:00")
- Positive format:
Returns
Total minutes elapsed since 00:00:
- Positive number for times in
HH:MMformat - Negative number for times in
-HH:MMformat 0for00:00or-00:00
Example Usage
playground.ts
Notes
- Handles both positive and negative time formats
- Maintains sign convention from input
- Returns raw numeric value (no rounding)
- Follows 24-hour time format
- Returns 0 for both
00:00and-00:00 - It internally uses extractHourMinute
Aliases
extractTotalMinutesFromTimegetTotalMinutesFromTime
Type Safety
Input is strictly validated through types:
type ClockTime = `${ClockHour}:${ClockMinute}`;
type ClockHour = '00'|'01'|...|'23';
type ClockMinute = '00'|'01'|...|'59';Use Cases
- Time duration calculations
- Timezone offset conversions
- Scheduling and time arithmetic
- Comparing time intervals
- Converting time formats for storage
Conclusion
The getTotalMinutes function provides:
- Simple conversion from time strings to minutes
- Accurate time math for calculations
- Consistent handling of signed times
- Type-safe operations through strict input validation
Last updated: Fri, May 22, 2026 07:46:19AM (Coordinated Universal Time)
