-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add sv-fi Finland Swedish locale (#1522)
- Loading branch information
1 parent
f369844
commit 8e32164
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Finland Swedish [sv-fi] | ||
import dayjs from 'dayjs' | ||
|
||
const locale = { | ||
name: 'sv-fi', | ||
weekdays: 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'), | ||
weekdaysShort: 'sön_mån_tis_ons_tor_fre_lör'.split('_'), | ||
weekdaysMin: 'sö_må_ti_on_to_fr_lö'.split('_'), | ||
months: 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'), | ||
monthsShort: 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'), | ||
weekStart: 1, | ||
yearStart: 4, | ||
ordinal: (n) => { | ||
const b = n % 10 | ||
const o = (b === 1) || (b === 2) ? 'a' : 'e' | ||
return `[${n}${o}]` | ||
}, | ||
formats: { | ||
LT: 'HH.mm', | ||
LTS: 'HH.mm.ss', | ||
L: 'DD.MM.YYYY', | ||
LL: 'D. MMMM YYYY', | ||
LLL: 'D. MMMM YYYY, [kl.] HH.mm', | ||
LLLL: 'dddd, D. MMMM YYYY, [kl.] HH.mm', | ||
l: 'D.M.YYYY', | ||
ll: 'D. MMM YYYY', | ||
lll: 'D. MMM YYYY, [kl.] HH.mm', | ||
llll: 'ddd, D. MMM YYYY, [kl.] HH.mm' | ||
}, | ||
relativeTime: { | ||
future: 'om %s', | ||
past: 'för %s sedan', | ||
s: 'några sekunder', | ||
m: 'en minut', | ||
mm: '%d minuter', | ||
h: 'en timme', | ||
hh: '%d timmar', | ||
d: 'en dag', | ||
dd: '%d dagar', | ||
M: 'en månad', | ||
MM: '%d månader', | ||
y: 'ett år', | ||
yy: '%d år' | ||
} | ||
} | ||
|
||
dayjs.locale(locale, null, true) | ||
|
||
export default locale | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import dayjs from '../../src' | ||
import localizedFormat from '../../src/plugin/localizedFormat' | ||
import '../../src/locale/sv-fi' | ||
|
||
dayjs.extend(localizedFormat) | ||
|
||
it('Finland Swedish locale', () => { | ||
// time | ||
expect(dayjs('2019-02-01 12:34:56').locale('sv-fi').format('LT')) | ||
.toBe('12.34') | ||
expect(dayjs('2019-02-01 23:45:56').locale('sv-fi').format('LTS')) | ||
.toBe('23.45.56') | ||
|
||
// date | ||
expect(dayjs('2019-02-01').locale('sv-fi').format('L')) | ||
.toBe('01.02.2019') | ||
expect(dayjs('2019-12-15').locale('sv-fi').format('LL')) | ||
.toBe('15. december 2019') | ||
// short | ||
expect(dayjs('2019-02-01').locale('sv-fi').format('l')) | ||
.toBe('1.2.2019') | ||
expect(dayjs('2019-12-15').locale('sv-fi').format('ll')) | ||
.toBe('15. dec 2019') | ||
|
||
// date and time | ||
expect(dayjs('2019-03-01 12:30').locale('sv-fi').format('LLL')) | ||
.toBe('1. mars 2019, kl. 12.30') | ||
expect(dayjs('2021-06-12 17:30').locale('sv-fi').format('LLLL')) | ||
.toBe('lördag, 12. juni 2021, kl. 17.30') | ||
// short | ||
expect(dayjs('2019-03-01 12:30').locale('sv-fi').format('lll')) | ||
.toBe('1. mar 2019, kl. 12.30') | ||
expect(dayjs('2021-06-01 17:30').locale('sv-fi').format('llll')) | ||
.toBe('tis, 1. jun 2021, kl. 17.30') | ||
}) |