date-vir 0.2.2 → 0.2.3

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.
@@ -54,9 +54,9 @@ function toHtmlInputString(fullDate, inputType, includeSeconds) {
54
54
  throw new Error(`Tried to create date string but no day was provided.`);
55
55
  }
56
56
  const dateParts = [
57
- fullDate.year,
58
- String(fullDate.month).padStart(2, '0'),
59
- String(fullDate.day).padStart(2, '0'),
57
+ String(Math.abs(fullDate.year)).padStart(4, '0'),
58
+ String(Math.abs(fullDate.month)).padStart(2, '0'),
59
+ String(Math.abs(fullDate.day)).padStart(2, '0'),
60
60
  ];
61
61
  return dateParts.join('-');
62
62
  }
@@ -71,9 +71,9 @@ function toHtmlInputString(fullDate, inputType, includeSeconds) {
71
71
  throw new Error(`Tried to create time string but no minutes were provided.`);
72
72
  }
73
73
  const timeParts = [
74
- String(fullDate.hour).padStart(2, '0'),
75
- String(fullDate.minute).padStart(2, '0'),
76
- includeSeconds ? String(fullDate.second).padStart(2, '0') : undefined,
74
+ String(Math.abs(fullDate.hour)).padStart(2, '0'),
75
+ String(Math.abs(fullDate.minute)).padStart(2, '0'),
76
+ includeSeconds ? String(Math.abs(fullDate.second ?? 0)).padStart(2, '0') : undefined,
77
77
  ].filter((entry) => entry != undefined);
78
78
  return timeParts.join(':');
79
79
  }
@@ -54,9 +54,9 @@ function toHtmlInputString(fullDate, inputType, includeSeconds) {
54
54
  throw new Error(`Tried to create date string but no day was provided.`);
55
55
  }
56
56
  const dateParts = [
57
- fullDate.year,
58
- String(fullDate.month).padStart(2, '0'),
59
- String(fullDate.day).padStart(2, '0'),
57
+ String(Math.abs(fullDate.year)).padStart(4, '0'),
58
+ String(Math.abs(fullDate.month)).padStart(2, '0'),
59
+ String(Math.abs(fullDate.day)).padStart(2, '0'),
60
60
  ];
61
61
  return dateParts.join('-');
62
62
  }
@@ -71,9 +71,9 @@ function toHtmlInputString(fullDate, inputType, includeSeconds) {
71
71
  throw new Error(`Tried to create time string but no minutes were provided.`);
72
72
  }
73
73
  const timeParts = [
74
- String(fullDate.hour).padStart(2, '0'),
75
- String(fullDate.minute).padStart(2, '0'),
76
- includeSeconds ? String(fullDate.second).padStart(2, '0') : undefined,
74
+ String(Math.abs(fullDate.hour)).padStart(2, '0'),
75
+ String(Math.abs(fullDate.minute)).padStart(2, '0'),
76
+ includeSeconds ? String(Math.abs(fullDate.second ?? 0)).padStart(2, '0') : undefined,
77
77
  ].filter((entry) => entry != undefined);
78
78
  return timeParts.join(':');
79
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "date-vir",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Easy and explicit dates and times",
5
5
  "keywords": [
6
6
  "date",