date-vir 0.0.1 → 0.1.1
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/cjs/full-date/calculate-relative-date.js +8 -0
- package/dist/cjs/full-date/parsing.js +7 -2
- package/dist/full-date/calculate-relative-date.d.ts +4 -0
- package/dist/full-date/calculate-relative-date.js +8 -0
- package/dist/full-date/parsing.d.ts +1 -1
- package/dist/full-date/parsing.js +7 -2
- package/package.json +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateRelativeDate = void 0;
|
|
4
|
+
const luxon_date_time_conversion_1 = require("./luxon-date-time-conversion");
|
|
5
|
+
function calculateRelativeDate(fullDate, relativeCalculation) {
|
|
6
|
+
return (0, luxon_date_time_conversion_1.parseLuxonDateTime)((0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).plus(relativeCalculation));
|
|
7
|
+
}
|
|
8
|
+
exports.calculateRelativeDate = calculateRelativeDate;
|
|
@@ -33,11 +33,16 @@ exports.parseStrangeString = parseStrangeString;
|
|
|
33
33
|
*/
|
|
34
34
|
function parseInputElementValue(elementOrValue, timezone) {
|
|
35
35
|
if (!elementOrValue) {
|
|
36
|
-
|
|
36
|
+
return undefined;
|
|
37
37
|
}
|
|
38
38
|
const value = (0, common_1.isRuntimeTypeOf)(elementOrValue, 'string')
|
|
39
39
|
? elementOrValue
|
|
40
40
|
: elementOrValue.value;
|
|
41
|
-
|
|
41
|
+
try {
|
|
42
|
+
return (0, create_full_date_1.createFullDate)(value, timezone);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
exports.parseInputElementValue = parseInputElementValue;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateRelativeDate = void 0;
|
|
4
|
+
const luxon_date_time_conversion_1 = require("./luxon-date-time-conversion");
|
|
5
|
+
function calculateRelativeDate(fullDate, relativeCalculation) {
|
|
6
|
+
return (0, luxon_date_time_conversion_1.parseLuxonDateTime)((0, luxon_date_time_conversion_1.toLuxonDateTime)(fullDate).plus(relativeCalculation));
|
|
7
|
+
}
|
|
8
|
+
exports.calculateRelativeDate = calculateRelativeDate;
|
|
@@ -24,4 +24,4 @@ export declare function parseStrangeString({ dateString, formatString, timezone,
|
|
|
24
24
|
* Read either an HTMLInputElement's value directly, or the value string retrieved from an
|
|
25
25
|
* HTMLInputElement. Handles both type="date" and type="time" <input> elements.
|
|
26
26
|
*/
|
|
27
|
-
export declare function parseInputElementValue(elementOrValue: HTMLInputElement | string | null | undefined, timezone: Timezone): FullDate;
|
|
27
|
+
export declare function parseInputElementValue(elementOrValue: HTMLInputElement | string | null | undefined, timezone: Timezone): FullDate | undefined;
|
|
@@ -33,11 +33,16 @@ exports.parseStrangeString = parseStrangeString;
|
|
|
33
33
|
*/
|
|
34
34
|
function parseInputElementValue(elementOrValue, timezone) {
|
|
35
35
|
if (!elementOrValue) {
|
|
36
|
-
|
|
36
|
+
return undefined;
|
|
37
37
|
}
|
|
38
38
|
const value = (0, common_1.isRuntimeTypeOf)(elementOrValue, 'string')
|
|
39
39
|
? elementOrValue
|
|
40
40
|
: elementOrValue.value;
|
|
41
|
-
|
|
41
|
+
try {
|
|
42
|
+
return (0, create_full_date_1.createFullDate)(value, timezone);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
42
47
|
}
|
|
43
48
|
exports.parseInputElementValue = parseInputElementValue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "date-vir",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Easy and explicit dates and times",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"date",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@augment-vir/common": "^14.2.2",
|
|
43
|
+
"@types/luxon": "^3.3.0",
|
|
43
44
|
"luxon": "^3.3.0",
|
|
44
45
|
"object-shape-tester": "^0.2.7"
|
|
45
46
|
},
|
|
@@ -47,7 +48,6 @@
|
|
|
47
48
|
"@augment-vir/browser-testing": "^14.2.2",
|
|
48
49
|
"@open-wc/testing": "^3.1.8",
|
|
49
50
|
"@types/chai": "^4.3.5",
|
|
50
|
-
"@types/luxon": "^3.3.0",
|
|
51
51
|
"@types/mocha": "^10.0.1",
|
|
52
52
|
"@web/dev-server-esbuild": "^0.4.1",
|
|
53
53
|
"@web/test-runner": "^0.16.1",
|