Added deployments overview
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
export const formatDate = (iso: string) => {
|
||||
if (!iso) return '—';
|
||||
const d = new Date(iso);
|
||||
return d.toLocaleDateString('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
};
|
||||
|
||||
export const formatRelativeDate = (iso: string) => {
|
||||
if (!iso) return '—';
|
||||
const d = new Date(iso);
|
||||
const now = new Date();
|
||||
const diffMs = now.getTime() - d.getTime();
|
||||
const diffSeconds = Math.floor(diffMs / 1000);
|
||||
const diffMinutes = Math.floor(diffSeconds / 60);
|
||||
const diffHours = Math.floor(diffMinutes / 60);
|
||||
const diffDays = Math.floor(diffHours / 24);
|
||||
|
||||
if (diffSeconds < 60) return `${diffSeconds} seconds ago`;
|
||||
if (diffMinutes < 60) return `${diffMinutes} minutes ago`;
|
||||
if (diffHours < 24) return `${diffHours} hours ago`;
|
||||
return `${diffDays} days ago`;
|
||||
};
|
||||
|
||||
export const formatDuration = (startIso: string, endIso: string, full: boolean = false) => {
|
||||
if (!startIso || !endIso) return '—';
|
||||
const start = new Date(startIso);
|
||||
const end = new Date(endIso);
|
||||
console.log('Calculating duration between', start, 'and', end);
|
||||
const diffMs = end.getTime() - start.getTime();
|
||||
const diffSeconds = Math.floor(diffMs / 1000);
|
||||
const diffMinutes = Math.floor(diffSeconds / 60);
|
||||
const diffHours = Math.floor(diffMinutes / 60);
|
||||
|
||||
if (diffSeconds < 60) return `${diffSeconds}${full ? ' seconds' : 's'}`;
|
||||
if (diffMinutes < 60) return `${diffMinutes}${full ? ' minutes' : 'm'}`;
|
||||
return `${diffHours}${full ? ' hours' : 'h'}`;
|
||||
};
|
||||
|
||||
export const formatDateRelativeOrAbsolute = (iso: string) => {
|
||||
const d = new Date(iso);
|
||||
const now = new Date();
|
||||
const diffMs = now.getTime() - d.getTime();
|
||||
const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
|
||||
|
||||
if (diffDays < 7) {
|
||||
return formatRelativeDate(iso);
|
||||
} else {
|
||||
return formatDate(iso);
|
||||
}
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
export const formatDate = (iso: string) => {
|
||||
if (!iso) return '—';
|
||||
const d = new Date(iso);
|
||||
return d.toLocaleDateString('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user