2023-12-25 17:21:39 +08:00
|
|
|
/**
|
|
|
|
|
* Convert the date format of YYYY-MM-DD to American writing
|
|
|
|
|
* @param date The date in format of YYYY-MM-DD.
|
|
|
|
|
*/
|
2024-04-03 22:08:27 +08:00
|
|
|
export const normalizeDate = (date: string = "1970-01-01"): string => {
|
2023-12-25 17:21:39 +08:00
|
|
|
let [year, month, day] = date.split("-");
|
|
|
|
|
let month_num = parseInt(month);
|
|
|
|
|
let day_num = parseInt(day);
|
|
|
|
|
const month_en: {
|
|
|
|
|
[index: number]: string;
|
|
|
|
|
} = {
|
|
|
|
|
1: "January",
|
|
|
|
|
2: "February",
|
|
|
|
|
3: "March",
|
|
|
|
|
4: "April",
|
|
|
|
|
5: "May",
|
|
|
|
|
6: "June",
|
|
|
|
|
7: "July",
|
|
|
|
|
8: "August",
|
|
|
|
|
9: "September",
|
|
|
|
|
10: "October",
|
|
|
|
|
11: "November",
|
|
|
|
|
12: "December",
|
|
|
|
|
};
|
|
|
|
|
return `${day_num} ${month_en[month_num]}, ${year}`;
|
|
|
|
|
};
|