Skip to content

Commit

Permalink
fix: code format
Browse files Browse the repository at this point in the history
  • Loading branch information
tonai committed Feb 6, 2025
1 parent 66e9b7e commit 8d52395
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 25 deletions.
5 changes: 1 addition & 4 deletions assets/pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ const Home = () => {
}, [params, user]);

return (
<Main
noticeProps={alertProps}
title="Le service public des cartes et données du territoire"
>
<Main noticeProps={alertProps} title="Le service public des cartes et données du territoire">
{params?.["authentication_failed"] === 1 && (
<Alert
severity="error"
Expand Down
42 changes: 21 additions & 21 deletions assets/utils/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,43 +38,43 @@ export const niceBytes = (x: string) => {
};

export const formatDate = (date: Date): string => {
return datefnsFormat(date, "dd MMMM yyyy", { locale: fr, timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone });
return datefnsFormat(date, "dd MMMM yyyy", { locale: fr, timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone });
};

export const formatDateTime = (date: Date): string => {
return (
datefnsFormat(date, "dd MMMM yyyy, HH", { locale: fr, timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone }) +
"h" +
datefnsFormat(date, "mm", { locale: fr, timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone })
);
return (
datefnsFormat(date, "dd MMMM yyyy, HH", { locale: fr, timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone }) +
"h" +
datefnsFormat(date, "mm", { locale: fr, timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone })
);
};

export const formatDateTimeLocal = (date: Date): string => {
return datefnsFormat(date, "yyyy-MM-dd'T'HH:mm", { locale: fr, timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone });
return datefnsFormat(date, "yyyy-MM-dd'T'HH:mm", { locale: fr, timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone });
};

export const formatDateFromISO = (isoDateString: string): string => {
const m = isoDateString.match(/([\d\-T:]+)\+\d{2}:\d{2}?/); // "2023-06-02T06:01:46+00:00"
if (m) {
isoDateString = m[1];
}
isoDateString = isoDateString.includes("Z") ? isoDateString : isoDateString + "Z";
const m = isoDateString.match(/([\d\-T:]+)\+\d{2}:\d{2}?/); // "2023-06-02T06:01:46+00:00"
if (m) {
isoDateString = m[1];
}
isoDateString = isoDateString.includes("Z") ? isoDateString : isoDateString + "Z";

const d = new Date(isoDateString);
const d = new Date(isoDateString);

return formatDateTime(d);
return formatDateTime(d);
};

export const formatDateWithoutTimeFromISO = (isoDateString: string): string => {
const m = isoDateString.match(/([\d\-T:]+)\+\d{2}:\d{2}?/); // "2023-06-02T06:01:46+00:00"
if (m) {
isoDateString = m[1];
}
isoDateString = isoDateString.includes("Z") ? isoDateString : isoDateString + "Z";
const m = isoDateString.match(/([\d\-T:]+)\+\d{2}:\d{2}?/); // "2023-06-02T06:01:46+00:00"
if (m) {
isoDateString = m[1];
}
isoDateString = isoDateString.includes("Z") ? isoDateString : isoDateString + "Z";

const d = new Date(isoDateString);
const d = new Date(isoDateString);

return formatDate(d);
return formatDate(d);
};

export const trimObject = (obj: object): object => {
Expand Down

0 comments on commit 8d52395

Please sign in to comment.