This commit is contained in:
2025-12-29 00:15:20 +08:00
parent ff9b8d6a87
commit a95f624fa2
24 changed files with 405 additions and 290 deletions

View File

@@ -16,9 +16,11 @@ export function makeFirstCharUpper(str: string): string {
* @returns The formatted date string.
*/
export function formatDate(dateString: string): string {
if (!dateString) return "";
const date = new Date(dateString);
if (Number.isNaN(date.getTime())) return "";
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
return `${year}${month}${day}`;
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
}