configure typescript + begin conversion
This commit is contained in:
@@ -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}`;
|
||||
}
|
||||
@@ -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}`;
|
||||
}
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
@@ -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}`;
|
||||
}
|
||||
Reference in New Issue
Block a user