MCPcopy Create free account
hub / github.com/amrlabib/react-timer-hook / getTimeFromMilliseconds

Method getTimeFromMilliseconds

src/utils/Time.ts:24–41  ·  view source on GitHub ↗
(millisecs: number, isCountDown = true)

Source from the content-addressed store, hash-verified

22
23export default class Time {
24 static getTimeFromMilliseconds(millisecs: number, isCountDown = true): TimeFromMillisecondsType {
25 const totalSeconds = isCountDown ? Math.ceil(millisecs / 1000) : Math.floor(millisecs / 1000);
26 const days = Math.floor(totalSeconds / (60 * 60 * 24));
27 const hours = Math.floor((totalSeconds % (60 * 60 * 24)) / (60 * 60));
28 const minutes = Math.floor((totalSeconds % (60 * 60)) / 60);
29 const seconds = Math.floor(totalSeconds % 60);
30 const milliseconds = Math.floor(millisecs % 1000);
31
32 return {
33 totalMilliseconds: millisecs,
34 totalSeconds,
35 milliseconds,
36 seconds,
37 minutes,
38 hours,
39 days,
40 };
41 }
42
43 static getMillisecondsFromExpiry(expiry: Date): number {
44 const now = new Date().getTime();

Callers 3

useTimerFunction · 0.80
useStopwatchFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected