mdtg 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +6 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # MDTG
2
2
 
3
- This is a package that helps you to convert `Date` objects to military date time and vice versa.
3
+ This is a package that helps you to convert `Date` objects to [military date time](https://en.wikipedia.org/wiki/Date-time_group) and vice versa.
4
4
 
5
5
  #### Limitations
6
6
 
package/index.js CHANGED
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  export class MDTG {
4
2
  #currentDate = null;
5
3
  static months = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
@@ -13,11 +11,11 @@ export class MDTG {
13
11
  }
14
12
 
15
13
  static isShortenedFormat(str) {
16
- return /^[0-9]{6}Z(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[0-9]{2}$/.test(str);
14
+ return /^[0-9]{6}Z(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[0-9]{2}$/i.test(str);
17
15
  }
18
16
 
19
17
  static isLongFormat(str) {
20
- return /^[0-9]{8}Z(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[0-9]{2}$/.test(str);
18
+ return /^[0-9]{8}Z(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)[0-9]{2}$/i.test(str);
21
19
  }
22
20
 
23
21
  #toShortMDT() {
@@ -76,7 +74,8 @@ export class MDTG {
76
74
  const day = Number.parseInt(str.slice(0, 2));
77
75
  const hours = Number.parseInt(str.slice(2, 4));
78
76
  const minutes = Number.parseInt(str.slice(4, 6));
79
- const month = MDTG.months.indexOf(str.slice(7, 10));
77
+ const _timezone = str.slice(6, 7);
78
+ const month = MDTG.months.indexOf(str.slice(7, 10).toLowerCase());
80
79
  const year = 2000 + Number.parseInt(str.slice(10, 12));
81
80
  const date = new Date(year, month, day, hours, minutes, 0, 0);
82
81
  return date;
@@ -85,7 +84,8 @@ export class MDTG {
85
84
  const hours = Number.parseInt(str.slice(2, 4));
86
85
  const minutes = Number.parseInt(str.slice(4, 6));
87
86
  const seconds = Number.parseInt(str.slice(6, 8));
88
- const month = MDTG.months.indexOf(str.slice(9, 12));
87
+ const _timezone = str.slice(8, 9);
88
+ const month = MDTG.months.indexOf(str.slice(9, 12).toLowerCase());
89
89
  const year = 2000 + Number.parseInt(str.slice(12, 14));
90
90
  const date = new Date(year, month, day, hours, minutes, seconds, 0);
91
91
  return date;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdtg",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {