date-vir 0.1.0 → 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.
@@ -33,11 +33,16 @@ exports.parseStrangeString = parseStrangeString;
33
33
  */
34
34
  function parseInputElementValue(elementOrValue, timezone) {
35
35
  if (!elementOrValue) {
36
- throw new Error('Cannot parse an empty element.');
36
+ return undefined;
37
37
  }
38
38
  const value = (0, common_1.isRuntimeTypeOf)(elementOrValue, 'string')
39
39
  ? elementOrValue
40
40
  : elementOrValue.value;
41
- return (0, create_full_date_1.createFullDate)(value, timezone);
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;
@@ -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
- throw new Error('Cannot parse an empty element.');
36
+ return undefined;
37
37
  }
38
38
  const value = (0, common_1.isRuntimeTypeOf)(elementOrValue, 'string')
39
39
  ? elementOrValue
40
40
  : elementOrValue.value;
41
- return (0, create_full_date_1.createFullDate)(value, timezone);
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.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Easy and explicit dates and times",
5
5
  "keywords": [
6
6
  "date",