Total Complexity | 5 |
Complexity/F | 0 |
Lines of Code | 29 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | type TDateType = string | number | Date; |
||
2 | |||
3 | export const formatDate = (date: TDateType): TDateType => { |
||
4 | const returnDate = new Date(date).toLocaleDateString("nb-NO", { |
||
5 | year: "numeric", |
||
6 | month: "long", |
||
7 | day: "numeric", |
||
8 | }); |
||
9 | if (returnDate === "Invalid Date") { |
||
10 | return date; |
||
11 | } |
||
12 | if (returnDate === "1. januar 1970") { |
||
13 | return "Søknadsfrist er ikke registrert"; |
||
14 | } |
||
15 | return returnDate; |
||
16 | }; |
||
17 | |||
18 | export const truncateTextLength = ( |
||
19 | inputString: string, |
||
20 | maxLength: number, |
||
21 | suffix: string |
||
22 | ): string => |
||
23 | inputString.length < maxLength |
||
24 | ? inputString |
||
25 | : `${inputString.substr( |
||
26 | 0, |
||
27 | inputString.substr(0, maxLength - suffix.length).lastIndexOf(" ") |
||
28 | )}${suffix}`; |
||
29 |