Passed
Push — master ( a78685...6b5b02 )
by Daniel
02:13 queued 48s
created

src/assets/utils/functions.ts   A

Complexity

Total Complexity 4
Complexity/F 0

Size

Lines of Code 16
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 13
mnd 4
bc 4
fnc 0
dl 0
loc 16
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
rs 10
1
/* Typescript typings */
2
type TDateType = string | number | Date;
3
4
export const formatDate = (date: TDateType): TDateType => {
5
  const returnDate = new Date(date).toLocaleDateString('nb-NO', {
6
    year: 'numeric',
7
    month: 'long',
8
    day: 'numeric',
9
  });
10
  if (returnDate === 'Invalid Date') { return date; }
11
  if (returnDate === '1. januar 1970') { return 'Søknadsfrist er ikke registrert'; }
12
  return returnDate;
13
};
14
15
export default formatDate;
16