fix: complete first version issue remediation
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
export function formatDateTime(value?: string | Date | null) {
|
||||
if (!value) return '-';
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) return '-';
|
||||
const pad = (part: number) => String(part).padStart(2, '0');
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
export function displayFileName(value: string) {
|
||||
if (!value || ![...value].some((character) => character.charCodeAt(0) > 0x7f) || [...value].some((character) => character.charCodeAt(0) > 0xff)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
try {
|
||||
const bytes = Uint8Array.from(value, (character) => character.charCodeAt(0));
|
||||
const decoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
||||
return decoded === value ? value : decoded;
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user