@trackunit/react-date-and-time-hooks 1.21.20 → 1.21.22
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/index.cjs.js +22 -1
- package/index.esm.js +22 -1
- package/package.json +9 -9
- package/src/useDateAndTime.d.ts +11 -1
- package/src/useTimezone.d.ts +11 -0
package/index.cjs.js
CHANGED
|
@@ -106,7 +106,18 @@ const GetAssetTimezoneDocument = {
|
|
|
106
106
|
|
|
107
107
|
const customTimeZoneSchema = zod.z.string().nullable();
|
|
108
108
|
/**
|
|
109
|
+
* Resolves the active timezone based on user preference, custom override, and optional asset location.
|
|
109
110
|
*
|
|
111
|
+
* Returns `current` (browser or custom override), `preferred` (resolved per user settings
|
|
112
|
+
* and optional asset), and `assetTimeZone` (fetched from the asset's GPS location).
|
|
113
|
+
*
|
|
114
|
+
* **When to use:**
|
|
115
|
+
* - Use `useTimezone` whenever you need to display or calculate dates in the correct
|
|
116
|
+
* timezone — especially on asset-detail pages where the machine's timezone may differ
|
|
117
|
+
* from the user's browser timezone.
|
|
118
|
+
* - Pair with `useDateAndTime` to format dates in the resolved `preferred` timezone.
|
|
119
|
+
* - Do **not** rely on `Intl.DateTimeFormat().resolvedOptions().timeZone` directly —
|
|
120
|
+
* this hook respects the user's preference setting (browser, machine, or custom).
|
|
110
121
|
*/
|
|
111
122
|
const useTimezone = ({ assetId } = {}) => {
|
|
112
123
|
const { timeZonePreference } = reactCoreHooks.useCurrentUserTimeZonePreference();
|
|
@@ -147,8 +158,18 @@ const useTimezone = ({ assetId } = {}) => {
|
|
|
147
158
|
};
|
|
148
159
|
|
|
149
160
|
/**
|
|
150
|
-
* Hook for
|
|
161
|
+
* Hook for locale- and timezone-aware date/time operations including formatting,
|
|
162
|
+
* arithmetic, comparisons, relative time, and duration formatting.
|
|
163
|
+
*
|
|
164
|
+
* ### When to use
|
|
165
|
+
* Use `useDateAndTime` whenever you need to format, compare, or manipulate dates in a
|
|
166
|
+
* way that respects the user's locale and timezone.
|
|
151
167
|
*
|
|
168
|
+
* ### When not to use
|
|
169
|
+
* - For raw UTC timestamps that never reach the UI — use plain `Date` math or
|
|
170
|
+
* `date-and-time-utils` directly.
|
|
171
|
+
* - For date picker value handling — the date/time components already consume locale
|
|
172
|
+
* and timezone internally.
|
|
152
173
|
*/
|
|
153
174
|
const useDateAndTime = () => {
|
|
154
175
|
const currentLocale = useLocale();
|
package/index.esm.js
CHANGED
|
@@ -104,7 +104,18 @@ const GetAssetTimezoneDocument = {
|
|
|
104
104
|
|
|
105
105
|
const customTimeZoneSchema = z.string().nullable();
|
|
106
106
|
/**
|
|
107
|
+
* Resolves the active timezone based on user preference, custom override, and optional asset location.
|
|
107
108
|
*
|
|
109
|
+
* Returns `current` (browser or custom override), `preferred` (resolved per user settings
|
|
110
|
+
* and optional asset), and `assetTimeZone` (fetched from the asset's GPS location).
|
|
111
|
+
*
|
|
112
|
+
* **When to use:**
|
|
113
|
+
* - Use `useTimezone` whenever you need to display or calculate dates in the correct
|
|
114
|
+
* timezone — especially on asset-detail pages where the machine's timezone may differ
|
|
115
|
+
* from the user's browser timezone.
|
|
116
|
+
* - Pair with `useDateAndTime` to format dates in the resolved `preferred` timezone.
|
|
117
|
+
* - Do **not** rely on `Intl.DateTimeFormat().resolvedOptions().timeZone` directly —
|
|
118
|
+
* this hook respects the user's preference setting (browser, machine, or custom).
|
|
108
119
|
*/
|
|
109
120
|
const useTimezone = ({ assetId } = {}) => {
|
|
110
121
|
const { timeZonePreference } = useCurrentUserTimeZonePreference();
|
|
@@ -145,8 +156,18 @@ const useTimezone = ({ assetId } = {}) => {
|
|
|
145
156
|
};
|
|
146
157
|
|
|
147
158
|
/**
|
|
148
|
-
* Hook for
|
|
159
|
+
* Hook for locale- and timezone-aware date/time operations including formatting,
|
|
160
|
+
* arithmetic, comparisons, relative time, and duration formatting.
|
|
161
|
+
*
|
|
162
|
+
* ### When to use
|
|
163
|
+
* Use `useDateAndTime` whenever you need to format, compare, or manipulate dates in a
|
|
164
|
+
* way that respects the user's locale and timezone.
|
|
149
165
|
*
|
|
166
|
+
* ### When not to use
|
|
167
|
+
* - For raw UTC timestamps that never reach the UI — use plain `Date` math or
|
|
168
|
+
* `date-and-time-utils` directly.
|
|
169
|
+
* - For date picker value handling — the date/time components already consume locale
|
|
170
|
+
* and timezone internally.
|
|
150
171
|
*/
|
|
151
172
|
const useDateAndTime = () => {
|
|
152
173
|
const currentLocale = useLocale();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-date-and-time-hooks",
|
|
3
|
-
"version": "1.21.
|
|
3
|
+
"version": "1.21.22",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"@graphql-codegen/cli": "^5.0.3",
|
|
11
11
|
"@graphql-typed-document-node/core": "^3.2.0",
|
|
12
12
|
"zod": "^3.25.76",
|
|
13
|
-
"@trackunit/iris-app-api": "1.17.
|
|
14
|
-
"@trackunit/react-core-contexts-test": "1.15.
|
|
15
|
-
"@trackunit/date-and-time-utils": "1.11.
|
|
16
|
-
"@trackunit/shared-utils": "1.13.
|
|
17
|
-
"@trackunit/react-core-hooks": "1.15.
|
|
18
|
-
"@trackunit/react-components": "1.22.
|
|
19
|
-
"@trackunit/react-graphql-hooks": "1.22.
|
|
20
|
-
"@trackunit/iris-app-runtime-core-api": "1.14.
|
|
13
|
+
"@trackunit/iris-app-api": "1.17.18",
|
|
14
|
+
"@trackunit/react-core-contexts-test": "1.15.28",
|
|
15
|
+
"@trackunit/date-and-time-utils": "1.11.116",
|
|
16
|
+
"@trackunit/shared-utils": "1.13.113",
|
|
17
|
+
"@trackunit/react-core-hooks": "1.15.28",
|
|
18
|
+
"@trackunit/react-components": "1.22.19",
|
|
19
|
+
"@trackunit/react-graphql-hooks": "1.22.19",
|
|
20
|
+
"@trackunit/iris-app-runtime-core-api": "1.14.27"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"@apollo/client": "^3.13.8",
|
package/src/useDateAndTime.d.ts
CHANGED
|
@@ -62,8 +62,18 @@ interface UseDateAndTimeReturn {
|
|
|
62
62
|
formatShortDate: (date: Date | undefined) => string;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Hook for
|
|
65
|
+
* Hook for locale- and timezone-aware date/time operations including formatting,
|
|
66
|
+
* arithmetic, comparisons, relative time, and duration formatting.
|
|
66
67
|
*
|
|
68
|
+
* ### When to use
|
|
69
|
+
* Use `useDateAndTime` whenever you need to format, compare, or manipulate dates in a
|
|
70
|
+
* way that respects the user's locale and timezone.
|
|
71
|
+
*
|
|
72
|
+
* ### When not to use
|
|
73
|
+
* - For raw UTC timestamps that never reach the UI — use plain `Date` math or
|
|
74
|
+
* `date-and-time-utils` directly.
|
|
75
|
+
* - For date picker value handling — the date/time components already consume locale
|
|
76
|
+
* and timezone internally.
|
|
67
77
|
*/
|
|
68
78
|
export declare const useDateAndTime: () => UseDateAndTimeReturn;
|
|
69
79
|
export {};
|
package/src/useTimezone.d.ts
CHANGED
|
@@ -27,7 +27,18 @@ interface TimezoneProps {
|
|
|
27
27
|
assetId?: string;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
+
* Resolves the active timezone based on user preference, custom override, and optional asset location.
|
|
30
31
|
*
|
|
32
|
+
* Returns `current` (browser or custom override), `preferred` (resolved per user settings
|
|
33
|
+
* and optional asset), and `assetTimeZone` (fetched from the asset's GPS location).
|
|
34
|
+
*
|
|
35
|
+
* **When to use:**
|
|
36
|
+
* - Use `useTimezone` whenever you need to display or calculate dates in the correct
|
|
37
|
+
* timezone — especially on asset-detail pages where the machine's timezone may differ
|
|
38
|
+
* from the user's browser timezone.
|
|
39
|
+
* - Pair with `useDateAndTime` to format dates in the resolved `preferred` timezone.
|
|
40
|
+
* - Do **not** rely on `Intl.DateTimeFormat().resolvedOptions().timeZone` directly —
|
|
41
|
+
* this hook respects the user's preference setting (browser, machine, or custom).
|
|
31
42
|
*/
|
|
32
43
|
export declare const useTimezone: ({ assetId }?: TimezoneProps) => UseTimezoneReturn;
|
|
33
44
|
export {};
|