Skip to content

Commit

Permalink
378 - Implement dates instead of xxx days
Browse files Browse the repository at this point in the history
  • Loading branch information
adabingw committed Jul 19, 2024
1 parent 27401bd commit 1ce249c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions dashboard/src/components/FileViewer/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,15 @@ export default function FileList({
</p>
<div className="grow"></div>

<p className="hidden min-w-[8ch] text-left text-gray-500 @xs:inline">
<p className="@xs:inline hidden min-w-[8ch] text-right text-gray-500">
{file.modification_time || file.creation_time
? formatTimeAgo(
Number(file.modification_time ?? file.creation_time) * 1000
)
: 'Unknown Creation Time'}
</p>

<p className="hidden min-w-[8ch] text-right text-gray-500 @sm:inline">
<p className="@sm:inline hidden min-w-[8ch] text-right text-gray-500">
{file.file_type === 'Directory'
? ''
: file.size
Expand Down
3 changes: 2 additions & 1 deletion dashboard/src/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ export const formatTimeAgo = (time_ms: number) => {
const diffMinutes = Math.floor(diff / (1000 * 60));
const diffSeconds = Math.floor(diff / 1000);
if (diffDays > 0) {
return `${diffDays} day${diffDays > 1 ? 's' : ''} ago`;
const date = new Date(time_ms);
return `${date.toLocaleString('default', { month: 'long', year: 'numeric', day: 'numeric' })}`;
} else if (diffHours > 0) {
return `${diffHours} hour${diffHours > 1 ? 's' : ''} ago`;
} else if (diffMinutes > 0) {
Expand Down

0 comments on commit 1ce249c

Please sign in to comment.