@zauru-sdk/common 2.0.74 → 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 +16 -0
- package/dist/esm/common.js +13 -6
- package/package.json +2 -2
- package/src/common.ts +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
|
|
14
|
+
## [2.0.75](https://github.com/intuitiva/zauru-typescript-sdk/compare/v2.0.74...v2.0.75) (2024-12-11)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @zauru-sdk/common
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [2.0.74](https://github.com/intuitiva/zauru-typescript-sdk/compare/v2.0.73...v2.0.74) (2024-12-11)
|
|
7
23
|
|
|
8
24
|
**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
|
|
@@ -558,7 +565,7 @@ exports.sortByProperty = sortByProperty;
|
|
|
558
565
|
* @returns A Promise of AxiosUtilsResponse<T>.
|
|
559
566
|
*/
|
|
560
567
|
async function handlePossibleAxiosErrors(action) {
|
|
561
|
-
const SECONDS_TO_TIMEOUT =
|
|
568
|
+
const SECONDS_TO_TIMEOUT = 20;
|
|
562
569
|
const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error(`Timeout skipped after ${SECONDS_TO_TIMEOUT} seconds`)), SECONDS_TO_TIMEOUT * 1000));
|
|
563
570
|
try {
|
|
564
571
|
const result = await Promise.race([action(), timeoutPromise]);
|
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
|
|
@@ -629,7 +635,7 @@ export const sortByProperty = (array: any[], property: string) => {
|
|
|
629
635
|
export async function handlePossibleAxiosErrors<T>(
|
|
630
636
|
action: () => Promise<T>
|
|
631
637
|
): Promise<AxiosUtilsResponse<T>> {
|
|
632
|
-
const SECONDS_TO_TIMEOUT =
|
|
638
|
+
const SECONDS_TO_TIMEOUT = 20;
|
|
633
639
|
|
|
634
640
|
const timeoutPromise = new Promise((_, reject) =>
|
|
635
641
|
setTimeout(
|