@0xchain/time-display 1.1.0-beta.11 → 1.1.0-beta.113

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.
Files changed (2) hide show
  1. package/dist/index.js +20 -19
  2. package/package.json +16 -4
package/dist/index.js CHANGED
@@ -1,23 +1,24 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import * as r from "react";
3
- import e from "dayjs";
4
- import l from "dayjs/plugin/utc";
5
- import u from "dayjs/plugin/timezone";
6
- e.extend(l);
7
- e.extend(u);
8
- function p({
9
- timestamp: o,
10
- format: t = "YYYY-MM-DD HH:mm:ss",
11
- className: i
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 [s, n] = r.useState("");
14
- return r.useEffect(() => {
15
- const m = e.tz.guess();
16
- console.log("userTimezone:", m);
17
- const c = e(o).tz(m).format(t);
18
- n(c);
19
- }, [o, t]), /* @__PURE__ */ f("time", { dateTime: e(o).toISOString(), className: i, children: s });
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
- p as default
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.11",
3
+ "version": "1.1.0-beta.113",
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
- "dependencies": {
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
+ }