@gem-sdk/components 2.0.1 → 2.0.2
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.
|
@@ -10,13 +10,21 @@ var core = require('@gem-sdk/core');
|
|
|
10
10
|
const ArticleDate = ({ setting, builderProps, styles })=>{
|
|
11
11
|
const { dateFormat } = setting ?? {};
|
|
12
12
|
const article = core.useArticleStore((s)=>s.article);
|
|
13
|
+
const { timezone } = core.useTimezone();
|
|
14
|
+
const convertTZ = (date, tzString)=>{
|
|
15
|
+
const tz = tzString?.split(' ')?.[1] ?? '';
|
|
16
|
+
return new Date(new Date(date).toLocaleString('en-US', {
|
|
17
|
+
timeZone: tz
|
|
18
|
+
}));
|
|
19
|
+
};
|
|
13
20
|
const formattedDate = React.useMemo(()=>{
|
|
14
|
-
const date = new Date(article.
|
|
21
|
+
const date = convertTZ(new Date(article.platformUpdatedAt), timezone ?? '');
|
|
15
22
|
const { locales, options } = JSON.parse(dateFormat ?? '{"locales":"en-US","options":{"month":"short","day":"2-digit","year":"numeric"}}');
|
|
16
23
|
return date.toLocaleDateString(locales, options);
|
|
17
24
|
}, [
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
article.platformUpdatedAt,
|
|
26
|
+
timezone,
|
|
27
|
+
dateFormat
|
|
20
28
|
]);
|
|
21
29
|
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
22
30
|
id: `shopify-text-element-${builderProps?.uid}`,
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Text from '../../text/components/Text.js';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import { useArticleStore } from '@gem-sdk/core';
|
|
4
|
+
import { useArticleStore, useTimezone } from '@gem-sdk/core';
|
|
5
5
|
|
|
6
6
|
const ArticleDate = ({ setting, builderProps, styles })=>{
|
|
7
7
|
const { dateFormat } = setting ?? {};
|
|
8
8
|
const article = useArticleStore((s)=>s.article);
|
|
9
|
+
const { timezone } = useTimezone();
|
|
10
|
+
const convertTZ = (date, tzString)=>{
|
|
11
|
+
const tz = tzString?.split(' ')?.[1] ?? '';
|
|
12
|
+
return new Date(new Date(date).toLocaleString('en-US', {
|
|
13
|
+
timeZone: tz
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
9
16
|
const formattedDate = useMemo(()=>{
|
|
10
|
-
const date = new Date(article.
|
|
17
|
+
const date = convertTZ(new Date(article.platformUpdatedAt), timezone ?? '');
|
|
11
18
|
const { locales, options } = JSON.parse(dateFormat ?? '{"locales":"en-US","options":{"month":"short","day":"2-digit","year":"numeric"}}');
|
|
12
19
|
return date.toLocaleDateString(locales, options);
|
|
13
20
|
}, [
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
article.platformUpdatedAt,
|
|
22
|
+
timezone,
|
|
23
|
+
dateFormat
|
|
16
24
|
]);
|
|
17
25
|
return /*#__PURE__*/ jsx("div", {
|
|
18
26
|
id: `shopify-text-element-${builderProps?.uid}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/components",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"format": "prettier --write \"./src/**/*.{ts,tsx}\""
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@gem-sdk/core": "2.0.
|
|
24
|
+
"@gem-sdk/core": "2.0.2",
|
|
25
25
|
"@gem-sdk/styles": "2.0.0",
|
|
26
26
|
"@types/react-transition-group": "^4.4.5"
|
|
27
27
|
},
|