Skip to content

Commit

Permalink
fiks
Browse files Browse the repository at this point in the history
  • Loading branch information
Oddsor committed Jan 21, 2025
1 parent 76e8e75 commit 754ae8d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/komponenter/Banner/BannerNAVAnsatt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import Nytt from '../NyttIAppen/Nytt';
import './Banner.less';
import { useAvtale } from '@/AvtaleProvider';
import { useFeatureToggles } from '@/FeatureToggleProvider';
import { addDays, max, differenceInDays, endOfDay, format } from 'date-fns';
import { nb } from 'date-fns/locale';
import { NORSK_DATO_FORMAT_FULL } from '@/utils/datoUtils';
import { addDays, max, differenceInDays, endOfDay } from 'date-fns';
import { formaterDato, NORSK_DATO_FORMAT_FULL } from '@/utils/datoUtils';

interface Props {
tekst: string;
Expand All @@ -36,7 +35,7 @@ const formaterSlettetidspunkt = (sistEndret: string) => {
if (antallDager < 14) {
return `${antallDager} dager`;
}
return `den ${format(slettetidspunkt, NORSK_DATO_FORMAT_FULL, { locale: nb })}`;
return `den ${formaterDato(slettetidspunkt, NORSK_DATO_FORMAT_FULL)}`;
};

const BannerNAVAnsatt: React.FunctionComponent<Props> = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/datoUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const NORSK_DATO_FORMAT_FULL = 'PPP';
/**
* Formater en dato gitt en formateringsstring.
*/
export const formaterDato = (dato: string, formatString: string = NORSK_DATO_OG_TID_FORMAT_FULL) => {
export const formaterDato = (dato: Date | string, formatString: string = NORSK_DATO_OG_TID_FORMAT_FULL) => {
try {
if (dato === '-999999999-01-01') return '';
const formatertDato = format(dato, formatString, { locale: nb });
Expand Down

0 comments on commit 754ae8d

Please sign in to comment.