Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions ui/helpers/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,12 @@ export const formatByteSize = function formatByteSize(bytes) {

export const formatExpires = function formatExpires(expires) {
if (!expires) return '';
const days = Math.floor((new Date(expires).getTime() - Date.now()) / 86400000);
if (Number.isNaN(days)) return '';
if (days <= 0) return 'expired';
const ms = new Date(expires).getTime() - Date.now();
if (Number.isNaN(ms)) return '';
if (ms <= 0) return 'expired';
const hours = Math.floor(ms / 3600000);
if (hours < 24) return `${hours}h`;
const days = Math.floor(hours / 24);
if (days < 60) return `${days}d`;
return `${Math.floor(days / 30)}mo`;
};
Expand Down