mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-16 21:30:39 -07:00
Update date formatting logic and replace binary assets
- Enhanced the formatDate function to handle date strings without timezone information by treating them as UTC. - Updated binary assets including screenshots and application images for improved visual representation.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 187 KiB |
@@ -7,7 +7,22 @@ export function formatDuration(seconds: number): string {
|
||||
}
|
||||
|
||||
export function formatDate(date: string | Date): string {
|
||||
return formatDistance(new Date(date), new Date(), { addSuffix: true });
|
||||
// Parse the date string - if it doesn't have timezone info, treat it as UTC
|
||||
let dateObj: Date;
|
||||
if (typeof date === 'string') {
|
||||
// If the string doesn't end with Z or have timezone offset, assume it's UTC
|
||||
const dateStr = date.trim();
|
||||
if (!dateStr.includes('Z') && !dateStr.match(/[+-]\d{2}:\d{2}$/)) {
|
||||
// No timezone info, treat as UTC
|
||||
dateObj = new Date(dateStr + 'Z');
|
||||
} else {
|
||||
dateObj = new Date(dateStr);
|
||||
}
|
||||
} else {
|
||||
dateObj = date;
|
||||
}
|
||||
|
||||
return formatDistance(dateObj, new Date(), { addSuffix: true }).replace(/^about /i, '');
|
||||
}
|
||||
|
||||
export function formatFileSize(bytes: number): string {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 852 KiB After Width: | Height: | Size: 860 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 187 KiB |
Binary file not shown.
Reference in New Issue
Block a user