@ariesclark/time
v0.4.1
Published
Fast, efficient, and easy-to-use time functions for TypeScript.
Readme
Fast, efficient, and easy-to-use time functions for TypeScript.
Packages
Installation
npm install @ariesclark/extensions
# Or directly, if you only need the number extension.
npm install @ariesclark/numberDocumentation
MaybeSuffix (type)
Milliseconds (type)
A duration in milliseconds.
DurationLiteral (type)
Duration (type)
A duration value.
Supports the following formats in both short and long form:
ms(milliseconds) e.g.20msor20as a number.s(seconds) e.g.1sor1 second.m(minutes) e.g.2mor2 minutes.h(hours) e.g.3hor3 hours.d(days) e.g.4dor4 days.w(weeks) e.g.5wor5 weeks.y(years) e.g.6yor6 years.
milliseconds (function)
[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.ms (variable)
[object Object],[object Object],[object Object]
now (function)
Current time in milliseconds.
returns: number
Timestamp (type)
[object Object],[object Object],[object Object],[object Object],[object Object]
InvalidTimestampError (variable)
timestamp (function)
[object Object],[object Object],[object Object]
Parameters:
- timestamp (
Timestamp)
returns: number
randomTime (function)
Parameters:
- offset (
Duration) - anchor (
number)
returns: number
