@trackunit/react-date-and-time-components 2.1.18-alpha-27ad777c16e.0 → 2.1.20
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 +3 -2
- package/index.esm.js +4 -3
- package/package.json +9 -9
package/index.cjs.js
CHANGED
|
@@ -127,12 +127,13 @@ const MS_PER_HOUR = 60 * 60 * 1000;
|
|
|
127
127
|
const DateTime = ({ value, format, className, style, fromNow = false, withTitle = false, titleFormat, timezone: timezoneProp, "data-testid": dataTestId, subtle = false, ref, ...rest }) => {
|
|
128
128
|
const { t } = useTranslation();
|
|
129
129
|
const locale = reactDateAndTimeHooks.useLocale();
|
|
130
|
+
const hourCycle = reactDateAndTimeHooks.useHourCycle();
|
|
130
131
|
const { preferred: preferredTimezone } = reactDateAndTimeHooks.useTimezone();
|
|
131
132
|
const timezone = timezoneProp ?? preferredTimezone;
|
|
132
133
|
const nowDate = react.useMemo(() => new Date(), []);
|
|
133
134
|
const date = sharedUtils.truthy(value) ? dateAndTimeUtils.toDateUtil(value) : nowDate;
|
|
134
|
-
const newDateTime = dateAndTimeUtils.formatDateUtil(date, format, timezone.id, locale);
|
|
135
|
-
const titleDateTime = withTitle ? dateAndTimeUtils.formatDateUtil(date, titleFormat, timezone.id, locale) : undefined;
|
|
135
|
+
const newDateTime = dateAndTimeUtils.formatDateUtil(date, format, timezone.id, locale, hourCycle);
|
|
136
|
+
const titleDateTime = withTitle ? dateAndTimeUtils.formatDateUtil(date, titleFormat, timezone.id, locale, hourCycle) : undefined;
|
|
136
137
|
const getTimeSince = react.useCallback((from, to) => {
|
|
137
138
|
const same = dateAndTimeUtils.isEqualUtil(from, to);
|
|
138
139
|
if (same) {
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
3
|
import { toDateUtil, formatDateUtil, isEqualUtil, timeSinceAuto, getHourCycle } from '@trackunit/date-and-time-utils';
|
|
4
|
-
import { useLocale, useTimezone, useDateAndTime } from '@trackunit/react-date-and-time-hooks';
|
|
4
|
+
import { useLocale, useHourCycle, useTimezone, useDateAndTime } from '@trackunit/react-date-and-time-hooks';
|
|
5
5
|
import { truthy, DateTimeFormat, nonNullable, objectKeys } from '@trackunit/shared-utils';
|
|
6
6
|
import { useMemo, useCallback, useState, useEffect, useRef, Children, isValidElement } from 'react';
|
|
7
7
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -125,12 +125,13 @@ const MS_PER_HOUR = 60 * 60 * 1000;
|
|
|
125
125
|
const DateTime = ({ value, format, className, style, fromNow = false, withTitle = false, titleFormat, timezone: timezoneProp, "data-testid": dataTestId, subtle = false, ref, ...rest }) => {
|
|
126
126
|
const { t } = useTranslation();
|
|
127
127
|
const locale = useLocale();
|
|
128
|
+
const hourCycle = useHourCycle();
|
|
128
129
|
const { preferred: preferredTimezone } = useTimezone();
|
|
129
130
|
const timezone = timezoneProp ?? preferredTimezone;
|
|
130
131
|
const nowDate = useMemo(() => new Date(), []);
|
|
131
132
|
const date = truthy(value) ? toDateUtil(value) : nowDate;
|
|
132
|
-
const newDateTime = formatDateUtil(date, format, timezone.id, locale);
|
|
133
|
-
const titleDateTime = withTitle ? formatDateUtil(date, titleFormat, timezone.id, locale) : undefined;
|
|
133
|
+
const newDateTime = formatDateUtil(date, format, timezone.id, locale, hourCycle);
|
|
134
|
+
const titleDateTime = withTitle ? formatDateUtil(date, titleFormat, timezone.id, locale, hourCycle) : undefined;
|
|
134
135
|
const getTimeSince = useCallback((from, to) => {
|
|
135
136
|
const same = isEqualUtil(from, to);
|
|
136
137
|
if (same) {
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-date-and-time-components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.20",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=24.x"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@trackunit/react-components": "2.1.
|
|
11
|
-
"@trackunit/date-and-time-utils": "1.13.
|
|
12
|
-
"@trackunit/react-date-and-time-hooks": "2.1.
|
|
13
|
-
"@trackunit/css-class-variance-utilities": "1.13.
|
|
14
|
-
"@trackunit/ui-icons": "1.13.
|
|
15
|
-
"@trackunit/shared-utils": "1.15.
|
|
16
|
-
"@trackunit/i18n-library-translation": "2.0.
|
|
17
|
-
"@trackunit/react-form-components": "2.1.
|
|
10
|
+
"@trackunit/react-components": "2.1.18",
|
|
11
|
+
"@trackunit/date-and-time-utils": "1.13.28",
|
|
12
|
+
"@trackunit/react-date-and-time-hooks": "2.1.19",
|
|
13
|
+
"@trackunit/css-class-variance-utilities": "1.13.26",
|
|
14
|
+
"@trackunit/ui-icons": "1.13.27",
|
|
15
|
+
"@trackunit/shared-utils": "1.15.26",
|
|
16
|
+
"@trackunit/i18n-library-translation": "2.0.20",
|
|
17
|
+
"@trackunit/react-form-components": "2.1.19",
|
|
18
18
|
"string-ts": "^2.0.0",
|
|
19
19
|
"tailwind-merge": "^2.0.0",
|
|
20
20
|
"react-calendar": "^6.0.0"
|