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

➔ moment.defineLocale(ꞌneꞌ).meridiemHour   B

Complexity

Conditions 8
Paths 14

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 8
c 1
b 0
f 0
nc 14
dl 14
loc 14
rs 7.7777
nop 2
1
//! moment.js locale configuration
2
//! locale : Nepalese [ne]
3
//! author : suvash : https://github.com/suvash
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 symbolMap = {
14
        '1': '१',
15
        '2': '२',
16
        '3': '३',
17
        '4': '४',
18
        '5': '५',
19
        '6': '६',
20
        '7': '७',
21
        '8': '८',
22
        '9': '९',
23
        '0': '०'
24
    },
25
    numberMap = {
26
        '१': '1',
27
        '२': '2',
28
        '३': '3',
29
        '४': '4',
30
        '५': '5',
31
        '६': '6',
32
        '७': '7',
33
        '८': '8',
34
        '९': '9',
35
        '०': '0'
36
    };
37
38
    var ne = moment.defineLocale('ne', {
39
        months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
40
        monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
41
        monthsParseExact : true,
42
        weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
43
        weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
44
        weekdaysMin : 'आ._सो._मं._बु._बि._शु._श.'.split('_'),
45
        weekdaysParseExact : true,
46
        longDateFormat : {
47
            LT : 'Aको h:mm बजे',
48
            LTS : 'Aको h:mm:ss बजे',
49
            L : 'DD/MM/YYYY',
50
            LL : 'D MMMM YYYY',
51
            LLL : 'D MMMM YYYY, Aको h:mm बजे',
52
            LLLL : 'dddd, D MMMM YYYY, Aको h:mm बजे'
53
        },
54
        preparse: function (string) {
55
            return string.replace(/[१२३४५६७८९०]/g, function (match) {
56
                return numberMap[match];
57
            });
58
        },
59
        postformat: function (string) {
60
            return string.replace(/\d/g, function (match) {
61
                return symbolMap[match];
62
            });
63
        },
64
        meridiemParse: /राति|बिहान|दिउँसो|साँझ/,
65
        meridiemHour : function (hour, meridiem) {
66
            if (hour === 12) {
67
                hour = 0;
68
            }
69
            if (meridiem === 'राति') {
70
                return hour < 4 ? hour : hour + 12;
71
            } else if (meridiem === 'बिहान') {
72
                return hour;
73
            } else if (meridiem === 'दिउँसो') {
74
                return hour >= 10 ? hour : hour + 12;
75
            } else if (meridiem === 'साँझ') {
0 ignored issues
show
Complexity Best Practice introduced by
There is no return statement if meridiem === "साँझ" is false. Are you sure this is correct? If so, consider adding return; explicitly.

This check looks for functions where a return statement is found in some execution paths, but not in all.

Consider this little piece of code

function isBig(a) {
    if (a > 5000) {
        return "yes";
    }
}

console.log(isBig(5001)); //returns yes
console.log(isBig(42)); //returns undefined

The function isBig will only return a specific value when its parameter is bigger than 5000. In any other case, it will implicitly return undefined.

This behaviour may not be what you had intended. In any case, you can add a return undefined to the other execution path to make the return value explicit.

Loading history...
76
                return hour + 12;
77
            }
78
        },
79
        meridiem : function (hour, minute, isLower) {
0 ignored issues
show
Unused Code introduced by
The parameter minute is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
Unused Code introduced by
The parameter isLower is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
80
            if (hour < 3) {
81
                return 'राति';
82
            } else if (hour < 12) {
83
                return 'बिहान';
84
            } else if (hour < 16) {
85
                return 'दिउँसो';
86
            } else if (hour < 20) {
87
                return 'साँझ';
88
            } else {
89
                return 'राति';
90
            }
91
        },
92
        calendar : {
93
            sameDay : '[आज] LT',
94
            nextDay : '[भोलि] LT',
95
            nextWeek : '[आउँदो] dddd[,] LT',
96
            lastDay : '[हिजो] LT',
97
            lastWeek : '[गएको] dddd[,] LT',
98
            sameElse : 'L'
99
        },
100
        relativeTime : {
101
            future : '%sमा',
102
            past : '%s अगाडि',
103
            s : 'केही क्षण',
104
            m : 'एक मिनेट',
105
            mm : '%d मिनेट',
106
            h : 'एक घण्टा',
107
            hh : '%d घण्टा',
108
            d : 'एक दिन',
109
            dd : '%d दिन',
110
            M : 'एक महिना',
111
            MM : '%d महिना',
112
            y : 'एक बर्ष',
113
            yy : '%d बर्ष'
114
        },
115
        week : {
116
            dow : 0, // Sunday is the first day of the week.
117
            doy : 6  // The week that contains Jan 1st is the first week of the year.
118
        }
119
    });
120
121
    return ne;
122
123
}));