configure typescript + begin conversion

This commit is contained in:
p2405951
2026-01-28 16:29:41 +01:00
parent 3c71e0c7b2
commit ea6fd94962
14 changed files with 381 additions and 128 deletions
-9
View File
@@ -1,9 +0,0 @@
export default function formatDate(d) {
const date = new Date(d);
const jj = String(date.getUTCDate()).padStart(2, '0');
const mm = String(date.getUTCMonth() + 1).padStart(2, '0');
const aaaa = date.getUTCFullYear();
return `${jj}/${mm}/${aaaa}`;
}
+9
View File
@@ -0,0 +1,9 @@
export default function formatDate(d: string | Date): string {
const date = d instanceof Date ? d : new Date(d);
const jj = String(date.getUTCDate()).padStart(2, "0");
const mm = String(date.getUTCMonth() + 1).padStart(2, "0");
const aaaa = date.getUTCFullYear();
return `${jj}/${mm}/${aaaa}`;
}
-32
View File
@@ -1,32 +0,0 @@
export function formatDateLetter(d) {
if (!d) return "Date inconnue";
const dateObj = new Date(d);
if (isNaN(dateObj.getTime())) return "Date invalide";
const monthNames = [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
];
const day = dateObj.getDate().toString().padStart(2, "0");
const month = monthNames[dateObj.getMonth()];
const year = dateObj.getFullYear();
const hours = dateObj.getHours().toString().padStart(2, "0");
const minutes = dateObj.getMinutes().toString().padStart(2, "0");
return `${day} ${month} ${year} à ${hours}:${minutes}`;
}
export function formatDateLetterJS(d) {
const monthNames = [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
];
const [year, month, day] = d.split('-');
return `${day} ${monthNames[parseInt(month) - 1]} ${year}`;
}
+65
View File
@@ -0,0 +1,65 @@
/*export function formatDateLetter(d) {
if (!d) return "Date inconnue";
const dateObj = new Date(d);
if (isNaN(dateObj.getTime())) return "Date invalide";
const monthNames = [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
];
const day = dateObj.getDate().toString().padStart(2, "0");
const month = monthNames[dateObj.getMonth()];
const year = dateObj.getFullYear();
const hours = dateObj.getHours().toString().padStart(2, "0");
const minutes = dateObj.getMinutes().toString().padStart(2, "0");
return `${day} ${month} ${year} à ${hours}:${minutes}`;
}
export function formatDateLetterJS(d) {
const monthNames = [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
];
const [year, month, day] = d.split('-');
return `${day} ${monthNames[parseInt(month) - 1]} ${year}`;
}*/
export function formatDateLetter(d: string | Date | null | undefined): string {
if (!d) return "Date inconnue";
const dateObj = d instanceof Date ? d : new Date(d);
if (isNaN(dateObj.getTime())) return "Date invalide";
const monthNames = [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
];
const day = dateObj.getDate().toString().padStart(2, "0");
const month = monthNames[dateObj.getMonth()];
const year = dateObj.getFullYear();
const hours = dateObj.getHours().toString().padStart(2, "0");
const minutes = dateObj.getMinutes().toString().padStart(2, "0");
return `${day} ${month} ${year} à ${hours}:${minutes}`;
}
export function formatDateLetterJS(d: string): string {
const monthNames = [
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin",
"Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
];
const [year, month, day] = d.split("-");
if (!year || !month || !day) return "Date invalide";
return `${day} ${monthNames[parseInt(month, 10) - 1]} ${year}`;
}
-8
View File
@@ -1,8 +0,0 @@
export default function formatTime(d) {
const date = new Date(d);
const hh = String(date.getUTCHours()).padStart(2, '0');
const min = String(date.getUTCMinutes()).padStart(2, '0');
return `${hh}:${min}`;
}
+12
View File
@@ -0,0 +1,12 @@
export default function formatTime(d: string | Date | null | undefined): string {
if (!d) return "Heure inconnue";
const date = d instanceof Date ? d : new Date(d);
if (isNaN(date.getTime())) return "Heure invalide";
const hh = String(date.getUTCHours()).padStart(2, "0");
const min = String(date.getUTCMinutes()).padStart(2, "0");
return `${hh}:${min}`;
}