@arkyn/shared 1.4.26 → 1.4.27

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.
@@ -1 +1 @@
1
- {"version":3,"file":"formatDateHour.d.ts","sourceRoot":"","sources":["../../src/formats/formatDateHour.ts"],"names":[],"mappings":"AAEA,iBAAS,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAUjD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"formatDateHour.d.ts","sourceRoot":"","sources":["../../src/formats/formatDateHour.ts"],"names":[],"mappings":"AAEA,iBAAS,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAYjD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -2,7 +2,8 @@ import { regex } from "../validations/regex";
2
2
  function formatDateHour(date, hour) {
3
3
  if (regex.HOUR.test(hour) === false)
4
4
  throw new Error("Invalid hour format");
5
- const dateHour = new Date(date);
5
+ const [day, month, year] = date.split("/").map(Number);
6
+ const dateHour = new Date(`${year}-${month}-${day}`);
6
7
  const [hours, minutes] = hour.split(":").map(Number);
7
8
  dateHour.setUTCHours(hours);
8
9
  dateHour.setUTCMinutes(minutes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/shared",
3
- "version": "1.4.26",
3
+ "version": "1.4.27",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./src/index.ts",
6
6
  "type": "module",
@@ -3,7 +3,9 @@ import { regex } from "../validations/regex";
3
3
  function formatDateHour(date: string, hour: string) {
4
4
  if (regex.HOUR.test(hour) === false) throw new Error("Invalid hour format");
5
5
 
6
- const dateHour = new Date(date);
6
+ const [day, month, year] = date.split("/").map(Number);
7
+
8
+ const dateHour = new Date(`${year}-${month}-${day}`);
7
9
  const [hours, minutes] = hour.split(":").map(Number);
8
10
 
9
11
  dateHour.setUTCHours(hours);