Lens restructure (#540)

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman authored and GitHub committed 2020-06-30 14:35:16 +03:00
1 parent e810eab39f
commit b7974827d2
786 files changed
+14567 -24066

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
// Formatting date duration in shorten format, e.g. "2d", or "25m"
import moment from "moment";
export function formatDuration(timeValue: number, compact: boolean) {
let result = "";
const duration = moment.duration(timeValue);
const suffixes = ["d", "h", "m"];
const durationValues = [
Math.round(duration.asDays()),
duration.hours(),
duration.minutes(),
];
durationValues.forEach((value, index) => {
if (value) result += value + suffixes[index] + " ";
});
if (compact) {
result = result.split(" ")[0];
}
if (!result) {
return "<1m";
}
return result;
}