Skip to content

Commit fcdd450

Browse files
committed
fixed data init in interval
1 parent 57f0ba0 commit fcdd450

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

dist/react-pure-time.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/react-pure-time.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ const Time = (props: Props) => {
152152
relativeTime: updateRelativeTime(date, state.currentUnit),
153153
});
154154
interval = window.setInterval(() => {
155+
const date = new Date(props.value);
155156
setState({
156157
...state,
157158
currentUnit: props.unit || bestFit(diff),

src/types.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,20 @@ export type Props = {
55
utc?: boolean;
66
format?: string;
77
relativeTime?: boolean;
8-
unit?: string;
8+
unit?: "year" | "month" | "week" | "day" | "hour" | "minute" | "second";
99
};
1010

1111
export type State = {
1212
relativeTime: string;
13-
currentUnit: string;
13+
currentUnit:
14+
| "year"
15+
| "month"
16+
| "week"
17+
| "day"
18+
| "hour"
19+
| "minute"
20+
| "second"
21+
| "";
1422
};
1523

1624
export type Diff = {

0 commit comments

Comments
 (0)