Phase 0.3: migrate date formatting to date-fns
This commit is contained in:
@@ -11,6 +11,7 @@ import { decodeMimeHeader } from '@/api/mail';
|
||||
import { Button } from '@/components/ui/Button';
|
||||
import { EmptyState } from '@/components/ui/EmptyState';
|
||||
import { FileText, Loader2 } from 'lucide-react';
|
||||
import { formatDateTime } from '@/utils/date';
|
||||
|
||||
export interface MailDetailProps {
|
||||
mail: Mail | null; loading: boolean;
|
||||
@@ -26,14 +27,7 @@ export interface MailDetailProps {
|
||||
}
|
||||
|
||||
function formatFullDate(dateStr: string): string {
|
||||
const date = new Date(dateStr);
|
||||
return date.toLocaleString([], {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
return formatDateTime(dateStr) || dateStr;
|
||||
}
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { decodeMimeHeader } from '@/api/mail';
|
||||
import { EmptyState } from '@/components/ui/EmptyState';
|
||||
import { Pagination } from '@/components/ui/Pagination';
|
||||
import { ChevronUp, Loader2, Paperclip, Star } from 'lucide-react';
|
||||
import { formatSmartDate } from '@/utils/date';
|
||||
|
||||
export interface MailListProps {
|
||||
mails: Mail[];
|
||||
@@ -30,12 +31,7 @@ export interface MailListProps {
|
||||
}
|
||||
|
||||
function formatDate(dateStr: string): string {
|
||||
const date = new Date(dateStr);
|
||||
const now = new Date();
|
||||
if (date.toDateString() === now.toDateString()) {
|
||||
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||||
}
|
||||
return date.toLocaleDateString([], { month: 'short', day: 'numeric' });
|
||||
return formatSmartDate(dateStr) || dateStr;
|
||||
}
|
||||
|
||||
export function MailList({
|
||||
|
||||
Reference in New Issue
Block a user