Skip to content

Commit

Permalink
feat(manager-react-component): add formatted date component (#15067)
Browse files Browse the repository at this point in the history
Resolve #15069

Signed-off-by: Thibault Barske <[email protected]>
  • Loading branch information
tibs245 authored Jan 23, 2025
1 parent 24545a3 commit bccd46b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {
FormattedDateProps,
useFormattedDate,
} from '../../hooks/date/useFormattedDate';

export const FormattedDate = (props: FormattedDateProps) => {
const formattedDate = useFormattedDate(props);

return <>{formattedDate}</>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ export enum DateFormat {
fullDisplay = 'fullDisplay',
}

export type FormattedDateProps = {
dateString: string;
unknownDateLabel?: string;
defaultLocale?: string;
format?: DateFormat;
};

export const useFormattedDate = ({
dateString,
defaultLocale = 'FR-fr',
unknownDateLabel = defaultUnknownDateLabel,
format = DateFormat.display,
}: {
dateString: string;
unknownDateLabel?: string;
defaultLocale?: string;
format?: DateFormat;
}) => {
}: FormattedDateProps) => {
const { i18n } = useTranslation();
const date = new Date(dateString);
const locale = i18n?.language?.replace('_', '-') || defaultLocale;
Expand Down

0 comments on commit bccd46b

Please sign in to comment.