refactor: rewrite video player
This commit is contained in:
34 files changed
+3766
-3007
No files matched your search
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Formats a given ticks value into a human-readable time string.
|
||||
* @param ticks - The ticks value to be formatted, typically in 100-nanosecond intervals.
|
||||
* @returns Formatted time string in the format HH:MM:SS.
|
||||
*/
|
||||
const ticksDisplay = (ticks: number) => {
|
||||
const time = Math.round(ticks / 10000);
|
||||
let formatedTime = "";
|
||||
let timeSec = Math.floor(time / 1000);
|
||||
let timeMin = Math.floor(timeSec / 60);
|
||||
timeSec -= timeMin * 60;
|
||||
timeSec = timeSec === 0 ? 0o0 : timeSec;
|
||||
const timeHr = Math.floor(timeMin / 60);
|
||||
timeMin -= timeHr * 60;
|
||||
formatedTime = `${timeHr.toLocaleString([], {
|
||||
minimumIntegerDigits: 2,
|
||||
useGrouping: false,
|
||||
})}:${timeMin.toLocaleString([], {
|
||||
minimumIntegerDigits: 2,
|
||||
useGrouping: false,
|
||||
})}:${timeSec.toLocaleString([], {
|
||||
minimumIntegerDigits: 2,
|
||||
useGrouping: false,
|
||||
})}`;
|
||||
return formatedTime;
|
||||
};
|
||||
|
||||
export default ticksDisplay;
|
||||
Reference in new issue
Block a user