@hardlydifficult/date-time 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/TimeSpan.d.ts +7 -0
- package/dist/TimeSpan.d.ts.map +1 -0
- package/dist/TimeSpan.js +14 -0
- package/dist/TimeSpan.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @hardlydifficult/date-time
|
|
2
|
+
|
|
3
|
+
Date and time utilities.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @hardlydifficult/date-time
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## TimeSpan
|
|
12
|
+
|
|
13
|
+
Human-readable duration type with millisecond conversion.
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { toMilliseconds, type TimeSpan } from '@hardlydifficult/date-time';
|
|
17
|
+
|
|
18
|
+
const delay: TimeSpan = { value: 1.5, unit: 'minutes' };
|
|
19
|
+
toMilliseconds(delay); // 90000
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Supported Units
|
|
23
|
+
|
|
24
|
+
`milliseconds`, `seconds`, `minutes`, `hours`, `days`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeSpan.d.ts","sourceRoot":"","sources":["../src/TimeSpan.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAChB,cAAc,GACd,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,CAAC;AAEX,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,CAAC;CAChB;AAUD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAEzD"}
|
package/dist/TimeSpan.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toMilliseconds = toMilliseconds;
|
|
4
|
+
const multipliers = {
|
|
5
|
+
milliseconds: 1,
|
|
6
|
+
seconds: 1_000,
|
|
7
|
+
minutes: 60_000,
|
|
8
|
+
hours: 3_600_000,
|
|
9
|
+
days: 86_400_000,
|
|
10
|
+
};
|
|
11
|
+
function toMilliseconds(timeSpan) {
|
|
12
|
+
return timeSpan.value * multipliers[timeSpan.unit];
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=TimeSpan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeSpan.js","sourceRoot":"","sources":["../src/TimeSpan.ts"],"names":[],"mappings":";;AAoBA,wCAEC;AAVD,MAAM,WAAW,GAA6B;IAC5C,YAAY,EAAE,CAAC;IACf,OAAO,EAAE,KAAK;IACd,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,UAAU;CACjB,CAAC;AAEF,SAAgB,cAAc,CAAC,QAAkB;IAC/C,OAAO,QAAQ,CAAC,KAAK,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toMilliseconds = void 0;
|
|
4
|
+
var TimeSpan_1 = require("./TimeSpan");
|
|
5
|
+
Object.defineProperty(exports, "toMilliseconds", { enumerable: true, get: function () { return TimeSpan_1.toMilliseconds; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,uCAA0E;AAAnC,0GAAA,cAAc,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hardlydifficult/date-time",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"test": "vitest run",
|
|
12
|
+
"test:watch": "vitest",
|
|
13
|
+
"test:coverage": "vitest run --coverage",
|
|
14
|
+
"lint": "tsc --noEmit",
|
|
15
|
+
"clean": "rm -rf dist"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "5.8.3",
|
|
19
|
+
"vitest": "1.6.1"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18.0.0"
|
|
23
|
+
}
|
|
24
|
+
}
|