plenna_utilities 1.7.1 → 1.7.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.
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatIsoDateToSpanish = exports.getDifferenceInMinutes = exports.formatHour = exports.formatDate = void 0;
4
4
  const formatDate = (isoDate) => {
5
- const date = new Date(isoDate);
6
- return date.toLocaleDateString('es-ES', {
5
+ const [year, month, day] = isoDate.split('-').map(Number);
6
+ const fecha = new Date(year, month - 1, day);
7
+ return fecha.toLocaleDateString('es-MX', {
7
8
  day: 'numeric',
8
9
  month: 'long',
9
10
  year: 'numeric'
@@ -14,11 +15,15 @@ const formatHour = (time24) => {
14
15
  const [hours, minutes, seconds] = time24.split(':').map(Number);
15
16
  const date = new Date();
16
17
  date.setHours(hours, minutes, seconds);
17
- return date.toLocaleTimeString('es-ES', {
18
+ let formatted = date.toLocaleTimeString('es-MX', {
18
19
  hour: 'numeric',
19
20
  minute: '2-digit',
20
21
  hour12: true
21
22
  });
23
+ if (formatted.startsWith('0:')) {
24
+ formatted = formatted.replace('0:', '12:');
25
+ }
26
+ return formatted;
22
27
  };
23
28
  exports.formatHour = formatHour;
24
29
  const getDifferenceInMinutes = (startTime, endTime) => {
@@ -34,10 +39,11 @@ const getDifferenceInMinutes = (startTime, endTime) => {
34
39
  exports.getDifferenceInMinutes = getDifferenceInMinutes;
35
40
  const formatIsoDateToSpanish = (isoString) => {
36
41
  const date = new Date(isoString);
37
- return date.toLocaleDateString('es-ES', {
42
+ return date.toLocaleDateString('es-MX', {
38
43
  day: 'numeric',
39
44
  month: 'long',
40
- year: 'numeric'
45
+ year: 'numeric',
46
+ timeZone: 'America/Mexico_City'
41
47
  });
42
48
  };
43
49
  exports.formatIsoDateToSpanish = formatIsoDateToSpanish;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plenna_utilities",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "plenna's utils for backend projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",