add human readable time

This commit is contained in:
fyears
2022-04-05 13:26:46 +08:00
parent b8c4a2bd9a
commit b39544b43b
4 changed files with 49 additions and 5 deletions
+16
View File
@@ -7,6 +7,12 @@ import XRegExp from "xregexp";
import * as origLog from "loglevel";
const log = origLog.getLogger("rs-default");
declare global {
interface Window {
moment: (...data: any) => any;
}
}
/**
* If any part of the file starts with '.' or '_' then it's a hidden file.
* @param item
@@ -303,3 +309,13 @@ export const atWhichLevel = (x: string) => {
export const checkHasSpecialCharForDir = (x: string) => {
return /[?/\\]/.test(x);
};
export const unixTimeToStr = (x: number | undefined | null) => {
if (x === undefined) {
return undefined;
}
if (x === null) {
return null;
}
return window.moment(x).format() as string;
};