From c91cd01e116640d9a0a61f306832f369ff1bab1e Mon Sep 17 00:00:00 2001 From: Ulad Kasach Date: Sat, 25 May 2024 20:08:42 -0400 Subject: [PATCH] feat(cast): toMillisecondsSinceEpoch --- src/casts/toMillisecondsSinceEpoch.ts | 7 +++++++ src/index.ts | 1 + 2 files changed, 8 insertions(+) create mode 100644 src/casts/toMillisecondsSinceEpoch.ts diff --git a/src/casts/toMillisecondsSinceEpoch.ts b/src/casts/toMillisecondsSinceEpoch.ts new file mode 100644 index 0000000..dbf51b4 --- /dev/null +++ b/src/casts/toMillisecondsSinceEpoch.ts @@ -0,0 +1,7 @@ +import { UniDate, UniDateTime } from '../domain/UniDateTime'; + +export const toMillisecondsSinceEpoch = ( + input: UniDate | UniDateTime, +): number => new Date(input).getTime(); + +export { toMillisecondsSinceEpoch as toMse }; diff --git a/src/index.ts b/src/index.ts index 5a5f587..f4c85ee 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,3 +3,4 @@ export * from './domain/UniDuration'; export * from './utils/sleep'; export * from './checks/isUniDate'; export * from './checks/isUniDateTime'; +export * from './casts/toMillisecondsSinceEpoch';