mdtg 4.1.5 → 4.1.7
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 +10 -10
- package/package.json +5 -2
- package/src/constants.js +0 -1
- package/src/format.js +1 -4
- package/src/validation.js +3 -1
package/README.md
CHANGED
|
@@ -15,16 +15,16 @@ import { formatMDTG, parseMDTG } from "mdtg";
|
|
|
15
15
|
|
|
16
16
|
const date = new Date(Date.UTC(2024, 7, 12, 11, 55, 30));
|
|
17
17
|
|
|
18
|
-
formatMDTG(date, { form: "short" });
|
|
19
|
-
formatMDTG(date, { form: "standard" });
|
|
20
|
-
formatMDTG(date);
|
|
18
|
+
formatMDTG(date, { form: "short" }); // "121155Z"
|
|
19
|
+
formatMDTG(date, { form: "standard" }); // "121155Zaug24"
|
|
20
|
+
formatMDTG(date); // "12115530Zaug24" (extended by default)
|
|
21
21
|
|
|
22
22
|
// A is UTC+1, so local time is one hour ahead of UTC.
|
|
23
23
|
const value = formatMDTG(date, { timezone: "A" }); // "12125530Aaug24"
|
|
24
|
-
parseMDTG(value).toISOString();
|
|
24
|
+
parseMDTG(value).toISOString(); // "2024-08-12T11:55:30.000Z"
|
|
25
25
|
|
|
26
26
|
parseMDTG("121155Zaug24").toISOString(); // "2024-08-12T11:55:00.000Z"
|
|
27
|
-
parseMDTG("121155Z");
|
|
27
|
+
parseMDTG("121155Z"); // month and year are current UTC month/year
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
### API
|
|
@@ -56,7 +56,7 @@ month and year and have no seconds. Years are interpreted as `2000` through
|
|
|
56
56
|
```js
|
|
57
57
|
import { parseMDTG } from "mdtg";
|
|
58
58
|
|
|
59
|
-
parseMDTG("121155Zaug24").toISOString();
|
|
59
|
+
parseMDTG("121155Zaug24").toISOString(); // "2024-08-12T11:55:00.000Z"
|
|
60
60
|
parseMDTG("12115530Zaug24").toISOString(); // "2024-08-12T11:55:30.000Z"
|
|
61
61
|
parseMDTG("12125530Aaug24").toISOString(); // "2024-08-12T11:55:30.000Z"
|
|
62
62
|
|
|
@@ -89,12 +89,12 @@ import {
|
|
|
89
89
|
isValidMDTG,
|
|
90
90
|
} from "mdtg";
|
|
91
91
|
|
|
92
|
-
isShortFormat("121155Z");
|
|
92
|
+
isShortFormat("121155Z"); // true
|
|
93
93
|
isStandardFormat("121155Zaug24"); // true
|
|
94
94
|
isExtendedFormat("12115530Zaug24"); // true
|
|
95
|
-
isMDTG("121155Zaug24");
|
|
96
|
-
isMDTG("invalid");
|
|
97
|
-
isMDTG("310224Zfeb24");
|
|
95
|
+
isMDTG("121155Zaug24"); // true
|
|
96
|
+
isMDTG("invalid"); // false
|
|
97
|
+
isMDTG("310224Zfeb24"); // true: structurally valid
|
|
98
98
|
isValidMDTG("310224Zfeb24"); // false: invalid calendar date
|
|
99
99
|
```
|
|
100
100
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdtg",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.7",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"lint": "biome lint .",
|
|
24
24
|
"prettier": "prettier **/*.yml",
|
|
25
25
|
"test": "vitest run",
|
|
26
|
+
"test:integration": "vitest run test/integration",
|
|
26
27
|
"test:mutation": "stryker run"
|
|
27
28
|
},
|
|
28
29
|
"keywords": [
|
|
@@ -37,8 +38,10 @@
|
|
|
37
38
|
"description": "This package offers you methods to convert Date Objects to military date time group and vice versa",
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@biomejs/biome": "2.5.15",
|
|
40
|
-
"@stryker-
|
|
41
|
+
"@systemfsoftware/stryker-js": "15.0.1",
|
|
42
|
+
"@systemfsoftware/stryker-js-vitest-runner": "8.0.3",
|
|
41
43
|
"@vitest/coverage-v8": "5.0.3",
|
|
44
|
+
"fast-check": "4.10.2",
|
|
42
45
|
"knip": "6.39.0",
|
|
43
46
|
"prettier": "3.9.9",
|
|
44
47
|
"vitest": "5.0.3"
|
package/src/constants.js
CHANGED
package/src/format.js
CHANGED
|
@@ -51,10 +51,7 @@ const buildStandard = (date, timezone) => {
|
|
|
51
51
|
return result;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
export const formatMDTG = (
|
|
55
|
-
date = new Date(),
|
|
56
|
-
{ form = FORM.EXTENDED, timezone: timezoneInput = "Z" } = {},
|
|
57
|
-
) => {
|
|
54
|
+
export const formatMDTG = (date = new Date(), { form, timezone: timezoneInput } = {}) => {
|
|
58
55
|
validateDate(date);
|
|
59
56
|
|
|
60
57
|
const timezone = validateTimezone(timezoneInput);
|
package/src/validation.js
CHANGED
|
@@ -23,7 +23,9 @@ export const validateDate = (date) => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export const validateTimezone = (timezone) => {
|
|
26
|
-
|
|
26
|
+
if (typeof timezone !== "string") return "Z";
|
|
27
|
+
|
|
28
|
+
const key = timezone.toUpperCase();
|
|
27
29
|
return key in OFFSETS ? key : "Z";
|
|
28
30
|
};
|
|
29
31
|
|