mirror of
https://github.com/Techtonic-Fault/homepage.git
synced 2026-01-22 21:18:22 +00:00
20 lines
440 B
TypeScript
20 lines
440 B
TypeScript
const months = {
|
|
"gennaio": 0,
|
|
"febbraio": 1,
|
|
"marzo": 2,
|
|
"aprile": 3,
|
|
"maggio": 4,
|
|
"giugno": 5,
|
|
"luglio": 6,
|
|
"agosto": 7,
|
|
"settembre": 8,
|
|
"ottobre": 9,
|
|
"novembre": 10,
|
|
"dicembre": 11,
|
|
}
|
|
|
|
export function parsePostDate(date: string) {
|
|
const [day, month, year] = date.split(" ");
|
|
const monthIndex = months[month.toLowerCase() as keyof typeof months];
|
|
return new Date(parseInt(year), monthIndex, parseInt(day));
|
|
} |