mirror of
https://github.com/idanoo/autobrr
synced 2025-07-25 17:59:14 +00:00
enhancement(web): improve functionality of utility components (#1094)
added missing Buffer definition for Stacktracey, made date functions more robust against undefined values enhancement: made simplifyDate and IsEmptyDate prone against undefined values fix: added a global Buffer definition (apparently required by Stacktracey)
This commit is contained in:
parent
087471a1f7
commit
64f81a4614
4 changed files with 29 additions and 6 deletions
|
@ -39,16 +39,16 @@ export function classNames(...classes: string[]) {
|
|||
export type COL_WIDTHS = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
||||
|
||||
// simplify date
|
||||
export function simplifyDate(date: string) {
|
||||
if (date !== "0001-01-01T00:00:00Z") {
|
||||
export function simplifyDate(date?: string) {
|
||||
if (typeof(date) === "string" && date !== "0001-01-01T00:00:00Z") {
|
||||
return formatISO9075(new Date(date));
|
||||
}
|
||||
return "n/a";
|
||||
}
|
||||
|
||||
// if empty date show as n/a
|
||||
export function IsEmptyDate(date: string) {
|
||||
if (date !== "0001-01-01T00:00:00Z") {
|
||||
export function IsEmptyDate(date?: string) {
|
||||
if (typeof(date) === "string" && date !== "0001-01-01T00:00:00Z") {
|
||||
return formatDistanceToNowStrict(
|
||||
new Date(date),
|
||||
{ addSuffix: true }
|
||||
|
@ -82,4 +82,4 @@ export const get = <T> (obj: T, path: string|Array<any>, defValue?: string) => {
|
|||
);
|
||||
// If found value is undefined return default value; otherwise return the value
|
||||
return result === undefined ? defValue : result;
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue