@ehmpathy/uni-time 1.2.0 → 1.4.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/dist/casts/toMillisecondsSinceEpoch.d.ts +3 -0
- package/dist/casts/toMillisecondsSinceEpoch.js +7 -0
- package/dist/casts/toMillisecondsSinceEpoch.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/manipulate/addDuration.d.ts +7 -0
- package/dist/manipulate/addDuration.js +15 -0
- package/dist/manipulate/addDuration.js.map +1 -0
- package/dist/manipulate/subDuration.d.ts +7 -0
- package/dist/manipulate/subDuration.js +15 -0
- package/dist/manipulate/subDuration.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toMse = exports.toMillisecondsSinceEpoch = void 0;
|
|
4
|
+
const toMillisecondsSinceEpoch = (input) => new Date(input).getTime();
|
|
5
|
+
exports.toMillisecondsSinceEpoch = toMillisecondsSinceEpoch;
|
|
6
|
+
exports.toMse = exports.toMillisecondsSinceEpoch;
|
|
7
|
+
//# sourceMappingURL=toMillisecondsSinceEpoch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toMillisecondsSinceEpoch.js","sourceRoot":"","sources":["../../src/casts/toMillisecondsSinceEpoch.ts"],"names":[],"mappings":";;;AAEO,MAAM,wBAAwB,GAAG,CACtC,KAA4B,EACpB,EAAE,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;AAF1B,QAAA,wBAAwB,4BAEE;AAEF,gBAJxB,gCAAwB,CAIK"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,3 +3,6 @@ export * from './domain/UniDuration';
|
|
|
3
3
|
export * from './utils/sleep';
|
|
4
4
|
export * from './checks/isUniDate';
|
|
5
5
|
export * from './checks/isUniDateTime';
|
|
6
|
+
export * from './casts/toMillisecondsSinceEpoch';
|
|
7
|
+
export * from './manipulate/addDuration';
|
|
8
|
+
export * from './manipulate/subDuration';
|
package/dist/index.js
CHANGED
|
@@ -19,4 +19,7 @@ __exportStar(require("./domain/UniDuration"), exports);
|
|
|
19
19
|
__exportStar(require("./utils/sleep"), exports);
|
|
20
20
|
__exportStar(require("./checks/isUniDate"), exports);
|
|
21
21
|
__exportStar(require("./checks/isUniDateTime"), exports);
|
|
22
|
+
__exportStar(require("./casts/toMillisecondsSinceEpoch"), exports);
|
|
23
|
+
__exportStar(require("./manipulate/addDuration"), exports);
|
|
24
|
+
__exportStar(require("./manipulate/subDuration"), exports);
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,uDAAqC;AACrC,gDAA8B;AAC9B,qDAAmC;AACnC,yDAAuC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,uDAAqC;AACrC,gDAA8B;AAC9B,qDAAmC;AACnC,yDAAuC;AACvC,mEAAiD;AACjD,2DAAyC;AACzC,2DAAyC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PickOne } from 'type-fns';
|
|
2
|
+
import { UniDate, UniDateTime } from '../domain/UniDateTime';
|
|
3
|
+
import { UniDuration } from '../domain/UniDuration';
|
|
4
|
+
/**
|
|
5
|
+
* subtract a duration from a datetime
|
|
6
|
+
*/
|
|
7
|
+
export declare const subDuration: (...args: [UniDateTime, UniDuration] | [UniDate, PickOne<Pick<Required<UniDuration>, 'days'>>]) => string & import("domain-glossaries").OfGlossary<"uni-time">;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.subDuration = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
const isUniDate_1 = require("../checks/isUniDate");
|
|
6
|
+
const isUniDateTime_1 = require("../checks/isUniDateTime");
|
|
7
|
+
const UniDuration_1 = require("../domain/UniDuration");
|
|
8
|
+
/**
|
|
9
|
+
* subtract a duration from a datetime
|
|
10
|
+
*/
|
|
11
|
+
const subDuration = (...args) => (0, isUniDate_1.isUniDate)(args[0])
|
|
12
|
+
? (0, isUniDate_1.asUniDate)((0, date_fns_1.subMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0, UniDuration_1.toMilliseconds)(args[1])))
|
|
13
|
+
: (0, isUniDateTime_1.asUniDateTime)((0, date_fns_1.subMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0, UniDuration_1.toMilliseconds)(args[1])));
|
|
14
|
+
exports.subDuration = subDuration;
|
|
15
|
+
//# sourceMappingURL=addDuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addDuration.js","sourceRoot":"","sources":["../../src/manipulate/addDuration.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;AAGrD,mDAA2D;AAC3D,2DAAwD;AAExD,uDAAoE;AAEpE;;GAEG;AACI,MAAM,WAAW,GAAG,CACzB,GAAG,IAEwD,EAC3D,EAAE,CACF,IAAA,qBAAS,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC,CAAC,IAAA,qBAAS,EAAC,IAAA,0BAAe,EAAC,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAA,4BAAc,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,IAAA,6BAAa,EACX,IAAA,0BAAe,EAAC,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAA,4BAAc,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAC5D,CAAC;AATK,QAAA,WAAW,eAShB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PickOne } from 'type-fns';
|
|
2
|
+
import { UniDate, UniDateTime } from '../domain/UniDateTime';
|
|
3
|
+
import { UniDuration } from '../domain/UniDuration';
|
|
4
|
+
/**
|
|
5
|
+
* add a duration to a datetime
|
|
6
|
+
*/
|
|
7
|
+
export declare const addDuration: (...args: [UniDateTime, UniDuration] | [UniDate, PickOne<Pick<Required<UniDuration>, 'days'>>]) => string & import("domain-glossaries").OfGlossary<"uni-time">;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDuration = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
const isUniDate_1 = require("../checks/isUniDate");
|
|
6
|
+
const isUniDateTime_1 = require("../checks/isUniDateTime");
|
|
7
|
+
const UniDuration_1 = require("../domain/UniDuration");
|
|
8
|
+
/**
|
|
9
|
+
* add a duration to a datetime
|
|
10
|
+
*/
|
|
11
|
+
const addDuration = (...args) => (0, isUniDate_1.isUniDate)(args[0])
|
|
12
|
+
? (0, isUniDate_1.asUniDate)((0, date_fns_1.addMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0, UniDuration_1.toMilliseconds)(args[1])))
|
|
13
|
+
: (0, isUniDateTime_1.asUniDateTime)((0, date_fns_1.addMilliseconds)((0, date_fns_1.parseISO)(args[0]), (0, UniDuration_1.toMilliseconds)(args[1])));
|
|
14
|
+
exports.addDuration = addDuration;
|
|
15
|
+
//# sourceMappingURL=subDuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subDuration.js","sourceRoot":"","sources":["../../src/manipulate/subDuration.ts"],"names":[],"mappings":";;;AAAA,uCAAqD;AAGrD,mDAA2D;AAC3D,2DAAwD;AAExD,uDAAoE;AAEpE;;GAEG;AACI,MAAM,WAAW,GAAG,CACzB,GAAG,IAEwD,EAC3D,EAAE,CACF,IAAA,qBAAS,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC,CAAC,IAAA,qBAAS,EAAC,IAAA,0BAAe,EAAC,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAA,4BAAc,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,IAAA,6BAAa,EACX,IAAA,0BAAe,EAAC,IAAA,mBAAQ,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAA,4BAAc,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAC5D,CAAC;AATK,QAAA,WAAW,eAShB"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@ehmpathy/uni-time",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "a glossary of universally intuitive time, date, and duration domain literals",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.4.0",
|
|
6
6
|
"repository": "ehmpathy/uni-time",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/uni-time",
|
|
8
8
|
"keywords": [
|