Refactoring: Split shared types into seperate modules and document alot.
This commit is contained in:
parent
e08ae944c4
commit
843cd37243
31 changed files with 2498 additions and 842 deletions
28
server/shared/utils/time.ts
Normal file
28
server/shared/utils/time.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* Utility functions for "wibbly wobbly timey wimey" stuff.
|
||||
*/
|
||||
import { UnixTimestampMilliseconds, UnixTimestampSeconds } from "../types";
|
||||
|
||||
/**
|
||||
* Converts an {@link UnixTimestampMilliseconds} to an {@link UnixTimestampSeconds} rounding down.
|
||||
*
|
||||
* @param ms - The timestamp in milliseconds.
|
||||
* @returns - The timestamp in seconds.
|
||||
*/
|
||||
export function toUnixTimestampSeconds(
|
||||
ms: UnixTimestampMilliseconds
|
||||
): UnixTimestampSeconds {
|
||||
return Math.floor(ms / 1000) as UnixTimestampSeconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an {@link UnixTimestampSeconds} to an {@link UnixTimestampMilliseconds}.
|
||||
*
|
||||
* @param s - The timestamp in seconds.
|
||||
* @returns - The timestamp in milliseconds.
|
||||
*/
|
||||
export function toUnixTimestampMilliseconds(
|
||||
s: UnixTimestampSeconds
|
||||
): UnixTimestampMilliseconds {
|
||||
return (s * 1000) as UnixTimestampMilliseconds;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue