Completed
Push — master ( b895c6...fa6d7b )
by Rain
03:32
created

➔ moment.defineLocale(ꞌsrꞌ).calendar.nextWeek   B

Complexity

Conditions 8
Paths 5

Size

Total Lines 15

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
cc 8
c 0
b 0
f 0
nc 5
dl 15
loc 15
rs 7.7777
nop 0
1
//! moment.js locale configuration
2
//! locale : Serbian [sr]
3
//! author : Milan Janačković<[email protected]> : https://github.com/milan-j
4
5 View Code Duplication
;(function (global, factory) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
6
   typeof exports === 'object' && typeof module !== 'undefined'
7
       && typeof require === 'function' ? factory(require('../moment')) :
8
   typeof define === 'function' && define.amd ? define(['../moment'], factory) :
9
   factory(global.moment)
10
}(this, function (moment) { 'use strict';
11
12
13
    var translator = {
14
        words: { //Different grammatical cases
15
            m: ['jedan minut', 'jedne minute'],
16
            mm: ['minut', 'minute', 'minuta'],
17
            h: ['jedan sat', 'jednog sata'],
18
            hh: ['sat', 'sata', 'sati'],
19
            dd: ['dan', 'dana', 'dana'],
20
            MM: ['mesec', 'meseca', 'meseci'],
21
            yy: ['godina', 'godine', 'godina']
22
        },
23
        correctGrammaticalCase: function (number, wordKey) {
24
            return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
25
        },
26
        translate: function (number, withoutSuffix, key) {
27
            var wordKey = translator.words[key];
28
            if (key.length === 1) {
29
                return withoutSuffix ? wordKey[0] : wordKey[1];
30
            } else {
31
                return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
32
            }
33
        }
34
    };
35
36
    var sr = moment.defineLocale('sr', {
37
        months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
38
        monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
39
        monthsParseExact: true,
40
        weekdays: 'nedelja_ponedeljak_utorak_sreda_četvrtak_petak_subota'.split('_'),
41
        weekdaysShort: 'ned._pon._uto._sre._čet._pet._sub.'.split('_'),
42
        weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
43
        weekdaysParseExact : true,
44
        longDateFormat: {
45
            LT: 'H:mm',
46
            LTS : 'H:mm:ss',
47
            L: 'DD. MM. YYYY',
48
            LL: 'D. MMMM YYYY',
49
            LLL: 'D. MMMM YYYY H:mm',
50
            LLLL: 'dddd, D. MMMM YYYY H:mm'
51
        },
52
        calendar: {
53
            sameDay: '[danas u] LT',
54
            nextDay: '[sutra u] LT',
55
            nextWeek: function () {
56
                switch (this.day()) {
1 ignored issue
show
Coding Style introduced by
As per coding-style, switch statements should have a default case.
Loading history...
57
                    case 0:
58
                        return '[u] [nedelju] [u] LT';
59
                    case 3:
60
                        return '[u] [sredu] [u] LT';
61
                    case 6:
62
                        return '[u] [subotu] [u] LT';
63
                    case 1:
64
                    case 2:
65
                    case 4:
66
                    case 5:
67
                        return '[u] dddd [u] LT';
68
                }
0 ignored issues
show
Comprehensibility introduced by
There is no default case in this switch, so nothing gets returned when all cases fail. You might want to consider adding a default or return undefined explicitly.
Loading history...
69
            },
70
            lastDay  : '[juče u] LT',
71
            lastWeek : function () {
72
                var lastWeekDays = [
73
                    '[prošle] [nedelje] [u] LT',
74
                    '[prošlog] [ponedeljka] [u] LT',
75
                    '[prošlog] [utorka] [u] LT',
76
                    '[prošle] [srede] [u] LT',
77
                    '[prošlog] [četvrtka] [u] LT',
78
                    '[prošlog] [petka] [u] LT',
79
                    '[prošle] [subote] [u] LT'
80
                ];
81
                return lastWeekDays[this.day()];
82
            },
83
            sameElse : 'L'
84
        },
85
        relativeTime : {
86
            future : 'za %s',
87
            past   : 'pre %s',
88
            s      : 'nekoliko sekundi',
89
            m      : translator.translate,
90
            mm     : translator.translate,
91
            h      : translator.translate,
92
            hh     : translator.translate,
93
            d      : 'dan',
94
            dd     : translator.translate,
95
            M      : 'mesec',
96
            MM     : translator.translate,
97
            y      : 'godinu',
98
            yy     : translator.translate
99
        },
100
        ordinalParse: /\d{1,2}\./,
101
        ordinal : '%d.',
102
        week : {
103
            dow : 1, // Monday is the first day of the week.
104
            doy : 7  // The week that contains Jan 1st is the first week of the year.
105
        }
106
    });
107
108
    return sr;
109
110
}));