Skip to content

Commit

Permalink
Fix: Type update
Browse files Browse the repository at this point in the history
  • Loading branch information
Sh031224 committed Mar 11, 2021
1 parent bdbaf68 commit 75bd37c
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 125 deletions.
20 changes: 4 additions & 16 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
export declare type TimeCountingDate = string | number | Date;
export interface TimeCountingOption {
objectTime?: string | number | Date;
lang?: "ko" | "en";
calculate?: {
justNow?: number;
second?: number;
minute?: number;
hour?: number;
day?: number;
week?: number;
month?: number;
};
}
declare const _default: (time: TimeCountingDate, option?: TimeCountingOption | undefined) => string;
export default _default;
import { TimeCountingDate, TimeCountingOption } from "./type";
declare const TimeCounting: (time: TimeCountingDate, option?: TimeCountingOption | undefined) => string;
export default TimeCounting;
export { TimeCountingOption, TimeCountingDate };
47 changes: 10 additions & 37 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = (function (time, option) {
var TimeCounting = function (time, option) {
var date = new Date(time);
var today = new Date();
var lang = "en";
Expand Down Expand Up @@ -70,65 +70,37 @@ exports.default = (function (time, option) {
}
else if (calc < calculate.second * 1000) {
var time_1 = Math.floor(calc / 1000);
var msg = lang === "en" && time_1 > 1
? "s after"
: lang === "en"
? " after"
: " 후";
var msg = lang === "en" && time_1 > 1 ? "s after" : lang === "en" ? " after" : " 후";
return "" + time_1 + message.second + msg;
}
else if (calc < 60 * calculate.minute * 1000) {
var time_2 = Math.floor(calc / 1000 / 60);
var msg = lang === "en" && time_2 > 1
? "s after"
: lang === "en"
? " after"
: " 후";
var msg = lang === "en" && time_2 > 1 ? "s after" : lang === "en" ? " after" : " 후";
return "" + time_2 + message.minute + msg;
}
else if (calc < 60 * 60 * calculate.hour * 1000) {
var time_3 = Math.floor(calc / 1000 / 60 / 60);
var msg = lang === "en" && time_3 > 1
? "s after"
: lang === "en"
? " after"
: " 후";
var msg = lang === "en" && time_3 > 1 ? "s after" : lang === "en" ? " after" : " 후";
return "" + time_3 + message.hour + msg;
}
else if (calc < 60 * 60 * 24 * calculate.day * 1000) {
var time_4 = Math.floor(calc / 1000 / 60 / 60 / 24);
var msg = lang === "en" && time_4 > 1
? "s after"
: lang === "en"
? " after"
: " 후";
var msg = lang === "en" && time_4 > 1 ? "s after" : lang === "en" ? " after" : " 후";
return "" + time_4 + message.day + msg;
}
else if (calc < 60 * 60 * 24 * 7 * calculate.week * 1000) {
var time_5 = Math.floor(calc / 1000 / 60 / 60 / 24 / 7);
var msg = lang === "en" && time_5 > 1
? "s after"
: lang === "en"
? " after"
: " 후";
var msg = lang === "en" && time_5 > 1 ? "s after" : lang === "en" ? " after" : " 후";
return "" + time_5 + message.week + msg;
}
else if (calc < 60 * 60 * 24 * 7 * 4 * calculate.month * 1000) {
var time_6 = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4);
var msg = lang === "en" && time_6 > 1
? "s after"
: lang === "en"
? " after"
: " 후";
var msg = lang === "en" && time_6 > 1 ? "s after" : lang === "en" ? " after" : " 후";
return "" + time_6 + message.month + msg;
}
else {
var time_7 = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4 / 12);
var msg = lang === "en" && time_7 > 1
? "s after"
: lang === "en"
? " after"
: " 후";
var msg = lang === "en" && time_7 > 1 ? "s after" : lang === "en" ? " after" : " 후";
return "" + time_7 + message.year + msg;
}
}
Expand Down Expand Up @@ -173,4 +145,5 @@ exports.default = (function (time, option) {
return "" + time_14 + message.year + msg;
}
}
});
};
exports.default = TimeCounting;
14 changes: 14 additions & 0 deletions dist/type.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export declare type TimeCountingDate = string | number | Date;
export interface TimeCountingOption {
objectTime?: string | number | Date;
lang?: "ko" | "en";
calculate?: {
justNow?: number;
second?: number;
minute?: number;
hour?: number;
day?: number;
week?: number;
month?: number;
};
}
2 changes: 2 additions & 0 deletions dist/type.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
91 changes: 19 additions & 72 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
export type TimeCountingDate = string | number | Date;

export interface TimeCountingOption {
objectTime?: string | number | Date;
lang?: "ko" | "en";
calculate?: {
justNow?: number;
second?: number;
minute?: number;
hour?: number;
day?: number;
week?: number;
month?: number;
};
}
import { TimeCountingDate, TimeCountingOption } from "./type";

export default (time: TimeCountingDate, option?: TimeCountingOption) => {
const TimeCounting = (time: TimeCountingDate, option?: TimeCountingOption) => {
const date: Date = new Date(time);

let today = new Date();
Expand Down Expand Up @@ -81,72 +67,37 @@ export default (time: TimeCountingDate, option?: TimeCountingOption) => {
return `${message.justNow}${msg}`;
} else if (calc < calculate.second * 1000) {
const time = Math.floor(calc / 1000);
const msg =
lang === "en" && time > 1
? "s after"
: lang === "en"
? " after"
: " 후";
const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후";

return `${time}${message.second}${msg}`;
} else if (calc < 60 * calculate.minute * 1000) {
const time = Math.floor(calc / 1000 / 60);
const msg =
lang === "en" && time > 1
? "s after"
: lang === "en"
? " after"
: " 후";
const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후";

return `${time}${message.minute}${msg}`;
} else if (calc < 60 * 60 * calculate.hour * 1000) {
const time = Math.floor(calc / 1000 / 60 / 60);
const msg =
lang === "en" && time > 1
? "s after"
: lang === "en"
? " after"
: " 후";
const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후";

return `${time}${message.hour}${msg}`;
} else if (calc < 60 * 60 * 24 * calculate.day * 1000) {
const time = Math.floor(calc / 1000 / 60 / 60 / 24);
const msg =
lang === "en" && time > 1
? "s after"
: lang === "en"
? " after"
: " 후";
const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후";

return `${time}${message.day}${msg}`;
} else if (calc < 60 * 60 * 24 * 7 * calculate.week * 1000) {
const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7);
const msg =
lang === "en" && time > 1
? "s after"
: lang === "en"
? " after"
: " 후";
const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후";

return `${time}${message.week}${msg}`;
} else if (calc < 60 * 60 * 24 * 7 * 4 * calculate.month * 1000) {
const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4);
const msg =
lang === "en" && time > 1
? "s after"
: lang === "en"
? " after"
: " 후";
const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후";

return `${time}${message.month}${msg}`;
} else {
const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4 / 12);
const msg =
lang === "en" && time > 1
? "s after"
: lang === "en"
? " after"
: " 후";
const msg = lang === "en" && time > 1 ? "s after" : lang === "en" ? " after" : " 후";

return `${time}${message.year}${msg}`;
}
Expand All @@ -157,46 +108,42 @@ export default (time: TimeCountingDate, option?: TimeCountingOption) => {
return `${message.justNow}${msg}`;
} else if (calc < calculate.second * 1000) {
const time = Math.floor(calc / 1000);
const msg =
lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";
const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";

return `${time}${message.second}${msg}`;
} else if (calc < 60 * calculate.minute * 1000) {
const time = Math.floor(calc / 1000 / 60);
const msg =
lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";
const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";

return `${time}${message.minute}${msg}`;
} else if (calc < 60 * 60 * calculate.hour * 1000) {
const time = Math.floor(calc / 1000 / 60 / 60);
const msg =
lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";
const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";

return `${time}${message.hour}${msg}`;
} else if (calc < 60 * 60 * 24 * calculate.day * 1000) {
const time = Math.floor(calc / 1000 / 60 / 60 / 24);
const msg =
lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";
const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";

return `${time}${message.day}${msg}`;
} else if (calc < 60 * 60 * 24 * 7 * calculate.week * 1000) {
const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7);
const msg =
lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";
const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";

return `${time}${message.week}${msg}`;
} else if (calc < 60 * 60 * 24 * 7 * 4 * calculate.month * 1000) {
const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4);
const msg =
lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";
const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";

return `${time}${message.month}${msg}`;
} else {
const time = Math.floor(calc / 1000 / 60 / 60 / 24 / 7 / 4 / 12);
const msg =
lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";
const msg = lang === "en" && time > 1 ? "s ago" : lang === "en" ? " ago" : " 전";

return `${time}${message.year}${msg}`;
}
}
};

export default TimeCounting;
export { TimeCountingOption, TimeCountingDate };
15 changes: 15 additions & 0 deletions src/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export type TimeCountingDate = string | number | Date;

export interface TimeCountingOption {
objectTime?: string | number | Date;
lang?: "ko" | "en";
calculate?: {
justNow?: number;
second?: number;
minute?: number;
hour?: number;
day?: number;
week?: number;
month?: number;
};
}

0 comments on commit 75bd37c

Please sign in to comment.