mdtg 4.1.2 → 4.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdtg",
3
- "version": "4.1.2",
3
+ "version": "4.1.4",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "type": "module",
package/src/format.js CHANGED
@@ -9,8 +9,7 @@ import {
9
9
 
10
10
  const normalizeNumber = (number) => String(number).padStart(2, "0");
11
11
 
12
- const createDateWithOffset = (date, offset) =>
13
- new Date(date.getTime() - offset * 60 * 60 * 1000);
12
+ const createDateWithOffset = (date, offset) => new Date(date.getTime() - offset * 60 * 60 * 1000);
14
13
 
15
14
  const buildShort = (date, timezone) => {
16
15
  const result = [date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes()]
@@ -26,18 +25,9 @@ const buildShort = (date, timezone) => {
26
25
  };
27
26
 
28
27
  const buildExtended = (date, timezone) => {
29
- const result = [
30
- date.getUTCDate(),
31
- date.getUTCHours(),
32
- date.getUTCMinutes(),
33
- date.getUTCSeconds(),
34
- ]
28
+ const result = [date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()]
35
29
  .map(normalizeNumber)
36
- .concat(
37
- timezone,
38
- MONTHS[date.getUTCMonth()],
39
- normalizeNumber(date.getUTCFullYear() % 100),
40
- )
30
+ .concat(timezone, MONTHS[date.getUTCMonth()], normalizeNumber(date.getUTCFullYear() % 100))
41
31
  .join("");
42
32
 
43
33
  if (!isExtendedFormat(result)) {
package/src/index.d.ts CHANGED
@@ -5,14 +5,8 @@ declare function formatMDTG(
5
5
  options?: { form?: MDTGFormat; timezone?: string },
6
6
  ): string;
7
7
 
8
- declare function isValidMDTG(
9
- mdtg: string,
10
- options?: { referenceDate?: Date },
11
- ): boolean;
12
- declare function parseMDTG(
13
- mdtg: string,
14
- options?: { referenceDate?: Date },
15
- ): Date;
8
+ declare function isValidMDTG(mdtg: string, options?: { referenceDate?: Date }): boolean;
9
+ declare function parseMDTG(mdtg: string, options?: { referenceDate?: Date }): Date;
16
10
 
17
11
  declare function isExtendedFormat(mdtg: string): boolean;
18
12
  declare function isMDTG(mdtg: string): boolean;
package/src/parse.js CHANGED
@@ -37,9 +37,7 @@ const parseWithMonth = (value, { hasSeconds, timezoneIndex, monthStart }) => {
37
37
  const minutes = parseInteger(value.slice(4, 6));
38
38
  const seconds = hasSeconds ? parseInteger(value.slice(6, 8)) : undefined;
39
39
  const timezone = value.slice(timezoneIndex, timezoneIndex + 1).toUpperCase();
40
- const month = MONTHS.indexOf(
41
- value.slice(monthStart, monthStart + 3).toLowerCase(),
42
- );
40
+ const month = MONTHS.indexOf(value.slice(monthStart, monthStart + 3).toLowerCase());
43
41
  const year = 2000 + parseInteger(value.slice(monthStart + 3, monthStart + 5));
44
42
 
45
43
  validateDateTime({
package/src/validation.js CHANGED
@@ -5,8 +5,7 @@ import {
5
5
  STANDARD_FORMAT_REGEX,
6
6
  } from "./constants.js";
7
7
 
8
- export const isShortFormat = (value) =>
9
- typeof value === "string" && SHORT_FORMAT_REGEX.test(value);
8
+ export const isShortFormat = (value) => typeof value === "string" && SHORT_FORMAT_REGEX.test(value);
10
9
 
11
10
  export const isStandardFormat = (value) =>
12
11
  typeof value === "string" && STANDARD_FORMAT_REGEX.test(value);
@@ -28,14 +27,7 @@ export const validateTimezone = (timezone) => {
28
27
  return key in OFFSETS ? key : "Z";
29
28
  };
30
29
 
31
- export const validateDateTime = ({
32
- year,
33
- month,
34
- day,
35
- hours,
36
- minutes,
37
- seconds,
38
- }) => {
30
+ export const validateDateTime = ({ year, month, day, hours, minutes, seconds }) => {
39
31
  const candidate = new Date(0);
40
32
  candidate.setUTCFullYear(year, month, day);
41
33
  candidate.setUTCHours(hours, minutes, seconds ?? 0, 0);