@0xchain/time-display 1.1.0-beta.11 → 1.1.0-beta.112
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/dist/index.js +20 -19
- package/package.json +16 -4
package/dist/index.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
timestamp
|
|
10
|
-
format
|
|
11
|
-
className
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import utc from "dayjs/plugin/utc";
|
|
5
|
+
import timezone from "dayjs/plugin/timezone";
|
|
6
|
+
dayjs.extend(utc);
|
|
7
|
+
dayjs.extend(timezone);
|
|
8
|
+
function Time({
|
|
9
|
+
timestamp,
|
|
10
|
+
format = "YYYY-MM-DD HH:mm:ss",
|
|
11
|
+
className
|
|
12
12
|
}) {
|
|
13
|
-
const [
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
console.log("userTimezone:",
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
}, [
|
|
13
|
+
const [localTime, setLocalTime] = React.useState("");
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
const userTimezone = dayjs.tz.guess();
|
|
16
|
+
console.log("userTimezone:", userTimezone);
|
|
17
|
+
const localizedTime = dayjs(timestamp).tz(userTimezone).format(format);
|
|
18
|
+
setLocalTime(localizedTime);
|
|
19
|
+
}, [timestamp, format]);
|
|
20
|
+
return /* @__PURE__ */ jsx("time", { dateTime: dayjs(timestamp).toISOString(), className, children: localTime });
|
|
20
21
|
}
|
|
21
22
|
export {
|
|
22
|
-
|
|
23
|
+
Time as default
|
|
23
24
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xchain/time-display",
|
|
3
|
-
"version": "1.1.0-beta.
|
|
3
|
+
"version": "1.1.0-beta.112",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -17,10 +17,22 @@
|
|
|
17
17
|
"dist",
|
|
18
18
|
"!**/*.tsbuildinfo"
|
|
19
19
|
],
|
|
20
|
-
"
|
|
21
|
-
"dayjs": "1.11.19"
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"dayjs": "1.11.19",
|
|
22
|
+
"react": "19.1.1",
|
|
23
|
+
"react-dom": "19.1.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"dayjs": "1.11.19",
|
|
27
|
+
"react": "19.1.1",
|
|
28
|
+
"react-dom": "19.1.1"
|
|
29
|
+
},
|
|
30
|
+
"nx": {
|
|
31
|
+
"tags": [
|
|
32
|
+
"type:util"
|
|
33
|
+
]
|
|
22
34
|
},
|
|
23
35
|
"publishConfig": {
|
|
24
36
|
"access": "public"
|
|
25
37
|
}
|
|
26
|
-
}
|
|
38
|
+
}
|