Skip to content

Commit 8e32164

Browse files
fix: add sv-fi Finland Swedish locale (#1522)
1 parent f369844 commit 8e32164

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

src/locale/sv-fi.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Finland Swedish [sv-fi]
2+
import dayjs from 'dayjs'
3+
4+
const locale = {
5+
name: 'sv-fi',
6+
weekdays: 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
7+
weekdaysShort: 'sön_mån_tis_ons_tor_fre_lör'.split('_'),
8+
weekdaysMin: 'sö_må_ti_on_to_fr_lö'.split('_'),
9+
months: 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
10+
monthsShort: 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
11+
weekStart: 1,
12+
yearStart: 4,
13+
ordinal: (n) => {
14+
const b = n % 10
15+
const o = (b === 1) || (b === 2) ? 'a' : 'e'
16+
return `[${n}${o}]`
17+
},
18+
formats: {
19+
LT: 'HH.mm',
20+
LTS: 'HH.mm.ss',
21+
L: 'DD.MM.YYYY',
22+
LL: 'D. MMMM YYYY',
23+
LLL: 'D. MMMM YYYY, [kl.] HH.mm',
24+
LLLL: 'dddd, D. MMMM YYYY, [kl.] HH.mm',
25+
l: 'D.M.YYYY',
26+
ll: 'D. MMM YYYY',
27+
lll: 'D. MMM YYYY, [kl.] HH.mm',
28+
llll: 'ddd, D. MMM YYYY, [kl.] HH.mm'
29+
},
30+
relativeTime: {
31+
future: 'om %s',
32+
past: 'för %s sedan',
33+
s: 'några sekunder',
34+
m: 'en minut',
35+
mm: '%d minuter',
36+
h: 'en timme',
37+
hh: '%d timmar',
38+
d: 'en dag',
39+
dd: '%d dagar',
40+
M: 'en månad',
41+
MM: '%d månader',
42+
y: 'ett år',
43+
yy: '%d år'
44+
}
45+
}
46+
47+
dayjs.locale(locale, null, true)
48+
49+
export default locale
50+

test/locale/sv-fi.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import dayjs from '../../src'
2+
import localizedFormat from '../../src/plugin/localizedFormat'
3+
import '../../src/locale/sv-fi'
4+
5+
dayjs.extend(localizedFormat)
6+
7+
it('Finland Swedish locale', () => {
8+
// time
9+
expect(dayjs('2019-02-01 12:34:56').locale('sv-fi').format('LT'))
10+
.toBe('12.34')
11+
expect(dayjs('2019-02-01 23:45:56').locale('sv-fi').format('LTS'))
12+
.toBe('23.45.56')
13+
14+
// date
15+
expect(dayjs('2019-02-01').locale('sv-fi').format('L'))
16+
.toBe('01.02.2019')
17+
expect(dayjs('2019-12-15').locale('sv-fi').format('LL'))
18+
.toBe('15. december 2019')
19+
// short
20+
expect(dayjs('2019-02-01').locale('sv-fi').format('l'))
21+
.toBe('1.2.2019')
22+
expect(dayjs('2019-12-15').locale('sv-fi').format('ll'))
23+
.toBe('15. dec 2019')
24+
25+
// date and time
26+
expect(dayjs('2019-03-01 12:30').locale('sv-fi').format('LLL'))
27+
.toBe('1. mars 2019, kl. 12.30')
28+
expect(dayjs('2021-06-12 17:30').locale('sv-fi').format('LLLL'))
29+
.toBe('lördag, 12. juni 2021, kl. 17.30')
30+
// short
31+
expect(dayjs('2019-03-01 12:30').locale('sv-fi').format('lll'))
32+
.toBe('1. mar 2019, kl. 12.30')
33+
expect(dayjs('2021-06-01 17:30').locale('sv-fi').format('llll'))
34+
.toBe('tis, 1. jun 2021, kl. 17.30')
35+
})

0 commit comments

Comments
 (0)