File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
apinf_packages/core/helper_functions Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,9 @@ export function formatDate (date, dateFormat = 'LL') {
24
24
}
25
25
26
26
export function getLocaleDateFormat ( ) {
27
+ // Use regex to define Finnish locale for different browsers
28
+ const regex = RegExp ( 'fi*' ) ;
29
+
27
30
// Get locale
28
31
const locale = navigator . languages ? navigator . languages [ 0 ] :
29
32
( navigator . language || navigator . userLanguage ) ;
@@ -33,15 +36,13 @@ export function getLocaleDateFormat () {
33
36
// Get locale data
34
37
const localeData = moment . localeData ( ) ;
35
38
36
- let format = localeData . longDateFormat ( 'L' ) ;
39
+ const format = localeData . longDateFormat ( 'L' ) ;
37
40
38
- if ( locale === 'fi' ) {
41
+ if ( regex . text ( locale ) ) {
39
42
// Remove year part (save the last dot)
40
- format = format . replace ( / Y Y Y Y / , '' ) ;
41
- } else {
42
- // Remove year part
43
- format = format . replace ( / .Y Y Y Y / , '' ) ;
43
+ return format . replace ( / Y Y Y Y / , '' ) ;
44
44
}
45
45
46
- return format ;
46
+ // Remove year part
47
+ return format . replace ( / .Y Y Y Y / , '' ) ;
47
48
}
You can’t perform that action at this time.
0 commit comments