UNPKG

2.3 kBJavaScriptView Raw
1// Icelandic [is]
2import dayjs from '../index';
3var texts = {
4 s: ['nokkrar sekúndur', 'nokkrar sekúndur', 'nokkrum sekúndum'],
5 m: ['mínúta', 'mínútu', 'mínútu'],
6 mm: ['mínútur', 'mínútur', 'mínútum'],
7 h: ['klukkustund', 'klukkustund', 'klukkustund'],
8 hh: ['klukkustundir', 'klukkustundir', 'klukkustundum'],
9 d: ['dagur', 'dag', 'degi'],
10 dd: ['dagar', 'daga', 'dögum'],
11 M: ['mánuður', 'mánuð', 'mánuði'],
12 MM: ['mánuðir', 'mánuði', 'mánuðum'],
13 y: ['ár', 'ár', 'ári'],
14 yy: ['ár', 'ár', 'árum']
15};
16
17function resolveTemplate(key, number, isFuture, withoutSuffix) {
18 var suffixIndex = isFuture ? 1 : 2;
19 var index = withoutSuffix ? 0 : suffixIndex;
20 var keyShouldBeSingular = key.length === 2 && number % 10 === 1;
21 var correctedKey = keyShouldBeSingular ? key[0] : key;
22 var unitText = texts[correctedKey];
23 var text = unitText[index];
24 return key.length === 1 ? text : "%d " + text;
25}
26
27function relativeTimeFormatter(number, withoutSuffix, key, isFuture) {
28 var template = resolveTemplate(key, number, isFuture, withoutSuffix);
29 return template.replace('%d', number);
30}
31
32var locale = {
33 name: 'is',
34 weekdays: 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'),
35 months: 'janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember'.split('_'),
36 weekStart: 1,
37 weekdaysShort: 'sun_mán_þri_mið_fim_fös_lau'.split('_'),
38 monthsShort: 'jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des'.split('_'),
39 weekdaysMin: 'Su_Má_Þr_Mi_Fi_Fö_La'.split('_'),
40 ordinal: function ordinal(n) {
41 return n;
42 },
43 formats: {
44 LT: 'H:mm',
45 LTS: 'H:mm:ss',
46 L: 'DD.MM.YYYY',
47 LL: 'D. MMMM YYYY',
48 LLL: 'D. MMMM YYYY [kl.] H:mm',
49 LLLL: 'dddd, D. MMMM YYYY [kl.] H:mm'
50 },
51 relativeTime: {
52 future: 'eftir %s',
53 past: 'fyrir %s síðan',
54 s: relativeTimeFormatter,
55 m: relativeTimeFormatter,
56 mm: relativeTimeFormatter,
57 h: relativeTimeFormatter,
58 hh: relativeTimeFormatter,
59 d: relativeTimeFormatter,
60 dd: relativeTimeFormatter,
61 M: relativeTimeFormatter,
62 MM: relativeTimeFormatter,
63 y: relativeTimeFormatter,
64 yy: relativeTimeFormatter
65 }
66};
67dayjs.locale(locale, null, true);
68export default locale;
\No newline at end of file