@grupalia/rn-ui-kit 0.36.0 → 0.36.1
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/lib/commonjs/hooks/useTimezonedDate.js +37 -36
- package/lib/commonjs/hooks/useTimezonedDate.js.map +1 -1
- package/lib/module/hooks/useTimezonedDate.js +38 -37
- package/lib/module/hooks/useTimezonedDate.js.map +1 -1
- package/lib/typescript/commonjs/hooks/useTimezonedDate.d.ts +0 -22
- package/lib/typescript/commonjs/hooks/useTimezonedDate.d.ts.map +1 -1
- package/lib/typescript/module/hooks/useTimezonedDate.d.ts +0 -22
- package/lib/typescript/module/hooks/useTimezonedDate.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -37,43 +37,44 @@ var _UIKitProvider = require("../UIKitProvider");
|
|
|
37
37
|
*/
|
|
38
38
|
function useTimezonedDate() {
|
|
39
39
|
const timezone = (0, _UIKitProvider.useTimezone)();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return _tz.TZDate.tz(timezone, date);
|
|
53
|
-
}
|
|
54
|
-
if (typeof date === 'string' || typeof date === 'number') {
|
|
55
|
-
return _tz.TZDate.tz(timezone, new Date(date));
|
|
56
|
-
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Create a TZDate instance in the configured timezone.
|
|
43
|
+
*
|
|
44
|
+
* @param date - Optional date to convert. If not provided, creates current time.
|
|
45
|
+
* @returns TZDate instance that works with all date-fns functions
|
|
46
|
+
*/
|
|
47
|
+
const tz = (0, _react.useCallback)(date => {
|
|
48
|
+
if (date === undefined) {
|
|
49
|
+
return _tz.TZDate.tz(timezone);
|
|
50
|
+
}
|
|
51
|
+
if (date instanceof Date) {
|
|
57
52
|
return _tz.TZDate.tz(timezone, date);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
53
|
+
}
|
|
54
|
+
if (typeof date === 'string' || typeof date === 'number') {
|
|
55
|
+
return _tz.TZDate.tz(timezone, new Date(date));
|
|
56
|
+
}
|
|
57
|
+
return _tz.TZDate.tz(timezone, date);
|
|
58
|
+
}, [timezone]);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Interpret a wall-clock date/time as occurring in the configured timezone.
|
|
62
|
+
* Returns a TZDate instance.
|
|
63
|
+
*
|
|
64
|
+
* e.g. to create a date for July 1, 2025 at 14:30 in the configured timezone:
|
|
65
|
+
*
|
|
66
|
+
* fromWallClock({ year: 2025, month: 7, day: 1, hour: 14, minute: 30 });
|
|
67
|
+
* => returns UTC datetime for 2025-07-01T14:30:00 -0600 (if timezone is America/Mexico_City)
|
|
68
|
+
* => 2025-07-01T20:30:00Z
|
|
69
|
+
*
|
|
70
|
+
* @param fields - Wall clock time components (month is 1-based)
|
|
71
|
+
* @returns TZDate instance in the configured timezone
|
|
72
|
+
*/
|
|
73
|
+
const fromWallClock = (0, _react.useCallback)(fields => new _tz.TZDate(fields.year, fields.month - 1, fields.day, fields.hour ?? 0, fields.minute ?? 0, fields.second ?? 0, fields.millisecond ?? 0, timezone), [timezone]);
|
|
74
|
+
return {
|
|
75
|
+
tz,
|
|
76
|
+
fromWallClock,
|
|
76
77
|
timezone
|
|
77
|
-
}
|
|
78
|
+
};
|
|
78
79
|
}
|
|
79
80
|
//# sourceMappingURL=useTimezonedDate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_tz","require","_react","_UIKitProvider","useTimezonedDate","timezone","useTimezone","
|
|
1
|
+
{"version":3,"names":["_tz","require","_react","_UIKitProvider","useTimezonedDate","timezone","useTimezone","tz","useCallback","date","undefined","TZDate","Date","fromWallClock","fields","year","month","day","hour","minute","second","millisecond"],"sourceRoot":"../../../src","sources":["hooks/useTimezonedDate.ts"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,gBAAgBA,CAAA,EAAG;EACjC,MAAMC,QAAQ,GAAG,IAAAC,0BAAW,EAAC,CAAC;;EAE9B;AACF;AACA;AACA;AACA;AACA;EACE,MAAMC,EAAE,GAAG,IAAAC,kBAAW,EAAEC,IAA6B,IAAa;IAChE,IAAIA,IAAI,KAAKC,SAAS,EAAE;MACtB,OAAOC,UAAM,CAACJ,EAAE,CAACF,QAAQ,CAAC;IAC5B;IACA,IAAII,IAAI,YAAYG,IAAI,EAAE;MACxB,OAAOD,UAAM,CAACJ,EAAE,CAACF,QAAQ,EAAEI,IAAI,CAAC;IAClC;IACA,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MACxD,OAAOE,UAAM,CAACJ,EAAE,CAACF,QAAQ,EAAE,IAAIO,IAAI,CAACH,IAAI,CAAC,CAAC;IAC5C;IACA,OAAOE,UAAM,CAACJ,EAAE,CAACF,QAAQ,EAAEI,IAAI,CAAC;EAClC,CAAC,EAAE,CAACJ,QAAQ,CAAC,CAAC;;EAEd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMQ,aAAa,GAAG,IAAAL,kBAAW,EAAEM,MAQlC,IAAK,IAAIH,UAAM,CACdG,MAAM,CAACC,IAAI,EACXD,MAAM,CAACE,KAAK,GAAG,CAAC,EAChBF,MAAM,CAACG,GAAG,EACVH,MAAM,CAACI,IAAI,IAAI,CAAC,EAChBJ,MAAM,CAACK,MAAM,IAAI,CAAC,EAClBL,MAAM,CAACM,MAAM,IAAI,CAAC,EAClBN,MAAM,CAACO,WAAW,IAAI,CAAC,EACvBhB,QACF,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEd,OAAO;IACLE,EAAE;IACFM,aAAa;IACbR;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { TZDate } from '@date-fns/tz';
|
|
4
|
-
import {
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
5
|
import { useTimezone } from "../UIKitProvider.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -34,43 +34,44 @@ import { useTimezone } from "../UIKitProvider.js";
|
|
|
34
34
|
*/
|
|
35
35
|
export function useTimezonedDate() {
|
|
36
36
|
const timezone = useTimezone();
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return TZDate.tz(timezone, date);
|
|
50
|
-
}
|
|
51
|
-
if (typeof date === 'string' || typeof date === 'number') {
|
|
52
|
-
return TZDate.tz(timezone, new Date(date));
|
|
53
|
-
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a TZDate instance in the configured timezone.
|
|
40
|
+
*
|
|
41
|
+
* @param date - Optional date to convert. If not provided, creates current time.
|
|
42
|
+
* @returns TZDate instance that works with all date-fns functions
|
|
43
|
+
*/
|
|
44
|
+
const tz = useCallback(date => {
|
|
45
|
+
if (date === undefined) {
|
|
46
|
+
return TZDate.tz(timezone);
|
|
47
|
+
}
|
|
48
|
+
if (date instanceof Date) {
|
|
54
49
|
return TZDate.tz(timezone, date);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
50
|
+
}
|
|
51
|
+
if (typeof date === 'string' || typeof date === 'number') {
|
|
52
|
+
return TZDate.tz(timezone, new Date(date));
|
|
53
|
+
}
|
|
54
|
+
return TZDate.tz(timezone, date);
|
|
55
|
+
}, [timezone]);
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Interpret a wall-clock date/time as occurring in the configured timezone.
|
|
59
|
+
* Returns a TZDate instance.
|
|
60
|
+
*
|
|
61
|
+
* e.g. to create a date for July 1, 2025 at 14:30 in the configured timezone:
|
|
62
|
+
*
|
|
63
|
+
* fromWallClock({ year: 2025, month: 7, day: 1, hour: 14, minute: 30 });
|
|
64
|
+
* => returns UTC datetime for 2025-07-01T14:30:00 -0600 (if timezone is America/Mexico_City)
|
|
65
|
+
* => 2025-07-01T20:30:00Z
|
|
66
|
+
*
|
|
67
|
+
* @param fields - Wall clock time components (month is 1-based)
|
|
68
|
+
* @returns TZDate instance in the configured timezone
|
|
69
|
+
*/
|
|
70
|
+
const fromWallClock = useCallback(fields => new TZDate(fields.year, fields.month - 1, fields.day, fields.hour ?? 0, fields.minute ?? 0, fields.second ?? 0, fields.millisecond ?? 0, timezone), [timezone]);
|
|
71
|
+
return {
|
|
72
|
+
tz,
|
|
73
|
+
fromWallClock,
|
|
73
74
|
timezone
|
|
74
|
-
}
|
|
75
|
+
};
|
|
75
76
|
}
|
|
76
77
|
//# sourceMappingURL=useTimezonedDate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TZDate","
|
|
1
|
+
{"version":3,"names":["TZDate","useCallback","useTimezone","useTimezonedDate","timezone","tz","date","undefined","Date","fromWallClock","fields","year","month","day","hour","minute","second","millisecond"],"sourceRoot":"../../../src","sources":["hooks/useTimezonedDate.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,cAAc;AACrC,SAASC,WAAW,QAAQ,OAAO;AAEnC,SAASC,WAAW,QAAQ,qBAAkB;;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EACjC,MAAMC,QAAQ,GAAGF,WAAW,CAAC,CAAC;;EAE9B;AACF;AACA;AACA;AACA;AACA;EACE,MAAMG,EAAE,GAAGJ,WAAW,CAAEK,IAA6B,IAAa;IAChE,IAAIA,IAAI,KAAKC,SAAS,EAAE;MACtB,OAAOP,MAAM,CAACK,EAAE,CAACD,QAAQ,CAAC;IAC5B;IACA,IAAIE,IAAI,YAAYE,IAAI,EAAE;MACxB,OAAOR,MAAM,CAACK,EAAE,CAACD,QAAQ,EAAEE,IAAI,CAAC;IAClC;IACA,IAAI,OAAOA,IAAI,KAAK,QAAQ,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MACxD,OAAON,MAAM,CAACK,EAAE,CAACD,QAAQ,EAAE,IAAII,IAAI,CAACF,IAAI,CAAC,CAAC;IAC5C;IACA,OAAON,MAAM,CAACK,EAAE,CAACD,QAAQ,EAAEE,IAAI,CAAC;EAClC,CAAC,EAAE,CAACF,QAAQ,CAAC,CAAC;;EAEd;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMK,aAAa,GAAGR,WAAW,CAAES,MAQlC,IAAK,IAAIV,MAAM,CACdU,MAAM,CAACC,IAAI,EACXD,MAAM,CAACE,KAAK,GAAG,CAAC,EAChBF,MAAM,CAACG,GAAG,EACVH,MAAM,CAACI,IAAI,IAAI,CAAC,EAChBJ,MAAM,CAACK,MAAM,IAAI,CAAC,EAClBL,MAAM,CAACM,MAAM,IAAI,CAAC,EAClBN,MAAM,CAACO,WAAW,IAAI,CAAC,EACvBb,QACF,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEd,OAAO;IACLC,EAAE;IACFI,aAAa;IACbL;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -28,26 +28,7 @@ import { TZDate } from '@date-fns/tz';
|
|
|
28
28
|
* });
|
|
29
29
|
*/
|
|
30
30
|
export declare function useTimezonedDate(): {
|
|
31
|
-
/**
|
|
32
|
-
* Create a TZDate instance in the configured timezone.
|
|
33
|
-
*
|
|
34
|
-
* @param date - Optional date to convert. If not provided, creates current time.
|
|
35
|
-
* @returns TZDate instance that works with all date-fns functions
|
|
36
|
-
*/
|
|
37
31
|
tz: (date?: Date | string | number) => TZDate;
|
|
38
|
-
/**
|
|
39
|
-
* Interpret a wall-clock date/time as occurring in the configured timezone.
|
|
40
|
-
* Returns a TZDate instance.
|
|
41
|
-
*
|
|
42
|
-
* e.g. to create a date for July 1, 2025 at 14:30 in the configured timezone:
|
|
43
|
-
*
|
|
44
|
-
* fromWallClock({ year: 2025, month: 7, day: 1, hour: 14, minute: 30 });
|
|
45
|
-
* => returns UTC datetime for 2025-07-01T14:30:00 -0600 (if timezone is America/Mexico_City)
|
|
46
|
-
* => 2025-07-01T20:30:00Z
|
|
47
|
-
*
|
|
48
|
-
* @param fields - Wall clock time components (month is 1-based)
|
|
49
|
-
* @returns TZDate instance in the configured timezone
|
|
50
|
-
*/
|
|
51
32
|
fromWallClock: (fields: {
|
|
52
33
|
year: number;
|
|
53
34
|
month: number;
|
|
@@ -57,9 +38,6 @@ export declare function useTimezonedDate(): {
|
|
|
57
38
|
second?: number;
|
|
58
39
|
millisecond?: number;
|
|
59
40
|
}) => TZDate;
|
|
60
|
-
/**
|
|
61
|
-
* The current configured timezone.
|
|
62
|
-
*/
|
|
63
41
|
timezone: string;
|
|
64
42
|
};
|
|
65
43
|
//# sourceMappingURL=useTimezonedDate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTimezonedDate.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTimezonedDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB;
|
|
1
|
+
{"version":3,"file":"useTimezonedDate.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTimezonedDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB;gBASC,IAAI,GAAG,MAAM,GAAG,MAAM,KAAG,MAAM;4BA0BnB;QACzC,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB;;EAgBF"}
|
|
@@ -28,26 +28,7 @@ import { TZDate } from '@date-fns/tz';
|
|
|
28
28
|
* });
|
|
29
29
|
*/
|
|
30
30
|
export declare function useTimezonedDate(): {
|
|
31
|
-
/**
|
|
32
|
-
* Create a TZDate instance in the configured timezone.
|
|
33
|
-
*
|
|
34
|
-
* @param date - Optional date to convert. If not provided, creates current time.
|
|
35
|
-
* @returns TZDate instance that works with all date-fns functions
|
|
36
|
-
*/
|
|
37
31
|
tz: (date?: Date | string | number) => TZDate;
|
|
38
|
-
/**
|
|
39
|
-
* Interpret a wall-clock date/time as occurring in the configured timezone.
|
|
40
|
-
* Returns a TZDate instance.
|
|
41
|
-
*
|
|
42
|
-
* e.g. to create a date for July 1, 2025 at 14:30 in the configured timezone:
|
|
43
|
-
*
|
|
44
|
-
* fromWallClock({ year: 2025, month: 7, day: 1, hour: 14, minute: 30 });
|
|
45
|
-
* => returns UTC datetime for 2025-07-01T14:30:00 -0600 (if timezone is America/Mexico_City)
|
|
46
|
-
* => 2025-07-01T20:30:00Z
|
|
47
|
-
*
|
|
48
|
-
* @param fields - Wall clock time components (month is 1-based)
|
|
49
|
-
* @returns TZDate instance in the configured timezone
|
|
50
|
-
*/
|
|
51
32
|
fromWallClock: (fields: {
|
|
52
33
|
year: number;
|
|
53
34
|
month: number;
|
|
@@ -57,9 +38,6 @@ export declare function useTimezonedDate(): {
|
|
|
57
38
|
second?: number;
|
|
58
39
|
millisecond?: number;
|
|
59
40
|
}) => TZDate;
|
|
60
|
-
/**
|
|
61
|
-
* The current configured timezone.
|
|
62
|
-
*/
|
|
63
41
|
timezone: string;
|
|
64
42
|
};
|
|
65
43
|
//# sourceMappingURL=useTimezonedDate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTimezonedDate.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTimezonedDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB;
|
|
1
|
+
{"version":3,"file":"useTimezonedDate.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useTimezonedDate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB;gBASC,IAAI,GAAG,MAAM,GAAG,MAAM,KAAG,MAAM;4BA0BnB;QACzC,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB;;EAgBF"}
|