@zauru-sdk/common 2.0.75 → 2.0.77
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/CHANGELOG.md +8 -0
- package/dist/esm/common.js +12 -5
- package/package.json +2 -2
- package/src/common.ts +11 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.77](https://github.com/intuitiva/zauru-typescript-sdk/compare/v2.0.76...v2.0.77) (2024-12-13)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @zauru-sdk/common
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [2.0.75](https://github.com/intuitiva/zauru-typescript-sdk/compare/v2.0.74...v2.0.75) (2024-12-11)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @zauru-sdk/common
|
package/dist/esm/common.js
CHANGED
|
@@ -347,11 +347,18 @@ const getFormattedDate = (dateString, withHours = true) => {
|
|
|
347
347
|
let date;
|
|
348
348
|
if (dateString) {
|
|
349
349
|
// Detectar el formato de la fecha
|
|
350
|
-
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}
|
|
351
|
-
// Formato ISO (UTC)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
350
|
+
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z?$/.test(dateString)) {
|
|
351
|
+
// Formato ISO (UTC o local)
|
|
352
|
+
if (dateString.endsWith("Z")) {
|
|
353
|
+
// ISO con UTC (Z)
|
|
354
|
+
date = new Date(dateString); // El constructor ya maneja UTC
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
// ISO sin UTC (hora local)
|
|
358
|
+
date = new Date(dateString);
|
|
359
|
+
// Ajustar a la hora local
|
|
360
|
+
date = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
|
361
|
+
}
|
|
355
362
|
}
|
|
356
363
|
else if (/^\d{4}-\d{2}-\d{2}$/.test(dateString)) {
|
|
357
364
|
// Formato YYYY-MM-DD
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/common",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.77",
|
|
4
4
|
"description": "Funciones de uso común en el desarrollo de webapps en Zauru",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"moment": "^2.30.1",
|
|
25
25
|
"moment-timezone": "^0.5.45"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "127c74c34eccffe40b39ad76957297833a8fc04c"
|
|
28
28
|
}
|
package/src/common.ts
CHANGED
|
@@ -389,11 +389,17 @@ export const getFormattedDate = (
|
|
|
389
389
|
|
|
390
390
|
if (dateString) {
|
|
391
391
|
// Detectar el formato de la fecha
|
|
392
|
-
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}
|
|
393
|
-
// Formato ISO (UTC)
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
392
|
+
if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z?$/.test(dateString)) {
|
|
393
|
+
// Formato ISO (UTC o local)
|
|
394
|
+
if (dateString.endsWith("Z")) {
|
|
395
|
+
// ISO con UTC (Z)
|
|
396
|
+
date = new Date(dateString); // El constructor ya maneja UTC
|
|
397
|
+
} else {
|
|
398
|
+
// ISO sin UTC (hora local)
|
|
399
|
+
date = new Date(dateString);
|
|
400
|
+
// Ajustar a la hora local
|
|
401
|
+
date = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
|
402
|
+
}
|
|
397
403
|
} else if (/^\d{4}-\d{2}-\d{2}$/.test(dateString)) {
|
|
398
404
|
// Formato YYYY-MM-DD
|
|
399
405
|
date = new Date(`${dateString}T00:00:00`); // Hora local
|