Fast, efficient, and easy-to-use time functions for TypeScript.
npm install @ariesclark/extensions
# Or directly, if you only need the number extension.
npm install @ariesclark/number
A duration in milliseconds.
A duration value.
Supports the following formats in both short and long form:
-
ms
(milliseconds) e.g.20ms
or20
as a number. -
s
(seconds) e.g.1s
or1 second
. -
m
(minutes) e.g.2m
or2 minutes
. -
h
(hours) e.g.3h
or3 hours
. -
d
(days) e.g.4d
or4 days
. -
w
(weeks) e.g.5w
or5 weeks
. -
y
(years) e.g.6y
or6 years
.
[object Object],[object Object],[object Object]
Parameters:
- value (
Duration
)
returns: number
ms('5m'); // 300000, 5 minutes in milliseconds, short form.
ms(300000); // 300000, 5 minutes in milliseconds, pass-through.
ms('2 hours'); // 7200000, 2 hours in milliseconds, long form.
[object Object],[object Object],[object Object]
Current time in milliseconds.
returns: number
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object]
Parameters:
- timestamp (
Timestamp
)
returns: number
Parameters:
- offset (
Duration
) - anchor (
number
)
returns: number