@trackunit/react-date-and-time-hooks 0.0.102 → 0.0.103

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 CHANGED
@@ -152,19 +152,20 @@ const useTimezone = ({ assetId } = {}) => {
152
152
  };
153
153
 
154
154
  /**
155
+ * Hook for managing date and time operations.
155
156
  *
156
157
  */
157
158
  const useDateAndTime = () => {
158
159
  const currentLocale = useLocale();
159
160
  const { current, assetTimeZone, preferred } = useTimezone();
160
- const currentTimeZone = current.id || preferred.id || (assetTimeZone === null || assetTimeZone === void 0 ? void 0 : assetTimeZone.id);
161
- const currentDate = dateAndTimeUtils.toZonedDateTimeUtil(polyfill.Temporal.Now.instant(), currentTimeZone);
161
+ const currentTimeZone = react.useMemo(() => current.id || preferred.id || (assetTimeZone === null || assetTimeZone === void 0 ? void 0 : assetTimeZone.id), [current, assetTimeZone, preferred]);
162
+ const currentDate = react.useMemo(() => dateAndTimeUtils.toZonedDateTimeUtil(polyfill.Temporal.Now.instant(), currentTimeZone), [currentTimeZone]);
162
163
  /**
163
164
  * Returns the current date and time.
164
165
  *
165
166
  * @returns {Date}
166
167
  */
167
- const nowDate = dateAndTimeUtils.toDateUtil(currentDate);
168
+ const nowDate = react.useMemo(() => dateAndTimeUtils.toDateUtil(currentDate), [currentDate]);
168
169
  /**
169
170
  * Formats a date using the current locale and time zone.
170
171
  *
package/index.esm.js CHANGED
@@ -150,19 +150,20 @@ const useTimezone = ({ assetId } = {}) => {
150
150
  };
151
151
 
152
152
  /**
153
+ * Hook for managing date and time operations.
153
154
  *
154
155
  */
155
156
  const useDateAndTime = () => {
156
157
  const currentLocale = useLocale();
157
158
  const { current, assetTimeZone, preferred } = useTimezone();
158
- const currentTimeZone = current.id || preferred.id || (assetTimeZone === null || assetTimeZone === void 0 ? void 0 : assetTimeZone.id);
159
- const currentDate = toZonedDateTimeUtil(Temporal.Now.instant(), currentTimeZone);
159
+ const currentTimeZone = useMemo(() => current.id || preferred.id || (assetTimeZone === null || assetTimeZone === void 0 ? void 0 : assetTimeZone.id), [current, assetTimeZone, preferred]);
160
+ const currentDate = useMemo(() => toZonedDateTimeUtil(Temporal.Now.instant(), currentTimeZone), [currentTimeZone]);
160
161
  /**
161
162
  * Returns the current date and time.
162
163
  *
163
164
  * @returns {Date}
164
165
  */
165
- const nowDate = toDateUtil(currentDate);
166
+ const nowDate = useMemo(() => toDateUtil(currentDate), [currentDate]);
166
167
  /**
167
168
  * Formats a date using the current locale and time zone.
168
169
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-date-and-time-hooks",
3
- "version": "0.0.102",
3
+ "version": "0.0.103",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -10,6 +10,7 @@ export type TemporalIsType = "past" | "present" | "future" | "between";
10
10
  export type TemporalSameType = Extract<TemporalTypes, "day" | "week" | "month" | "year">;
11
11
  export type TemporalTimeRounding = Extract<TemporalTypes, "hour" | "minute" | "second">;
12
12
  /**
13
+ * Hook for managing date and time operations.
13
14
  *
14
15
  */
15
16
  export declare const useDateAndTime: () => {