Skip to content

Commit

Permalink
fix: 시간 예외처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
baegofda committed Apr 6, 2023
1 parent 5f936de commit 3f11bb6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default {
},
time: {
control: { type: "text" },
description: "타임 세일 기간",
description:
"타임 세일 기간 ex) Thu Apr 06 2023 10:52:19 GMT+0900 (한국 표준시)",
table: {
type: {
summary: "dayjs.ConfigType",
Expand All @@ -59,11 +60,19 @@ export default {
} as Meta;

export const Default = (props) => {
const { time, type, size, text, dateTime } = props;
const dayjs = getDayjs();
const now = dayjs();

return (
<div style={{ backgroundColor: props.type === "white" && "gray" }}>
<Timer {...props} time={dayjs()} />
<Timer
time={time || now}
type={type}
size={size}
text={text}
dateTime={dateTime}
/>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export const getRemainingTime = (
const target = dayjs(targetDate);
const now = dayjs();
const diff = target.diff(now);
const isReachedTime = now.isSame(target) || diff <= 0;
if (isReachedTime) return "00:00:00";

const days = dayjs.duration(diff).days();

// NOTE: 당일이라면 일자는 표시x
Expand Down

0 comments on commit 3f11bb6

Please sign in to comment.