mirror of
https://github.com/Mastermindzh/tidal-hifi.git
synced 2025-08-06 04:46:49 +02:00
feat: reworked the api, added duration/current in seconds + shuffle & repeat
This commit is contained in:
14
src/features/time/parse.ts
Normal file
14
src/features/time/parse.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Convert a HH:MM:SS string (or variants such as MM:SS or SS) to plain seconds
|
||||
* @param duration in HH:MM:SS format
|
||||
* @returns number of seconds in duration
|
||||
*/
|
||||
export const convertDurationToSeconds = (duration: string) => {
|
||||
return duration
|
||||
.split(":")
|
||||
.reverse()
|
||||
.map((val) => Number(val))
|
||||
.reduce((previous, current, index) => {
|
||||
return index === 0 ? current : previous + current * Math.pow(60, index);
|
||||
}, 0);
|
||||
};
|
Reference in New Issue
Block a user