Update Moment.js from 2.8.3 to 2.8.4
[lhc/web/wiklou.git] / resources / lib / moment / locale / uk.js
1 // moment.js locale configuration
2 // locale : ukrainian (uk)
3 // author : zemlanin : https://github.com/zemlanin
4 // Author : Menelion Elensúle : https://github.com/Oire
5
6 (function (factory) {
7 if (typeof define === 'function' && define.amd) {
8 define(['moment'], factory); // AMD
9 } else if (typeof exports === 'object') {
10 module.exports = factory(require('../moment')); // Node
11 } else {
12 factory((typeof global !== 'undefined' ? global : this).moment); // node or other global
13 }
14 }(function (moment) {
15 function plural(word, num) {
16 var forms = word.split('_');
17 return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
18 }
19
20 function relativeTimeWithPlural(number, withoutSuffix, key) {
21 var format = {
22 'mm': 'хвилина_хвилини_хвилин',
23 'hh': 'година_години_годин',
24 'dd': 'день_дні_днів',
25 'MM': 'місяць_місяці_місяців',
26 'yy': 'рік_роки_років'
27 };
28 if (key === 'm') {
29 return withoutSuffix ? 'хвилина' : 'хвилину';
30 }
31 else if (key === 'h') {
32 return withoutSuffix ? 'година' : 'годину';
33 }
34 else {
35 return number + ' ' + plural(format[key], +number);
36 }
37 }
38
39 function monthsCaseReplace(m, format) {
40 var months = {
41 'nominative': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_'),
42 'accusative': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_')
43 },
44
45 nounCase = (/D[oD]? *MMMM?/).test(format) ?
46 'accusative' :
47 'nominative';
48
49 return months[nounCase][m.month()];
50 }
51
52 function weekdaysCaseReplace(m, format) {
53 var weekdays = {
54 'nominative': 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'),
55 'accusative': 'неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу'.split('_'),
56 'genitive': 'неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи'.split('_')
57 },
58
59 nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ?
60 'accusative' :
61 ((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ?
62 'genitive' :
63 'nominative');
64
65 return weekdays[nounCase][m.day()];
66 }
67
68 function processHoursFunction(str) {
69 return function () {
70 return str + 'о' + (this.hours() === 11 ? 'б' : '') + '] LT';
71 };
72 }
73
74 return moment.defineLocale('uk', {
75 months : monthsCaseReplace,
76 monthsShort : 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'),
77 weekdays : weekdaysCaseReplace,
78 weekdaysShort : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
79 weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
80 longDateFormat : {
81 LT : 'HH:mm',
82 LTS : 'LT:ss',
83 L : 'DD.MM.YYYY',
84 LL : 'D MMMM YYYY р.',
85 LLL : 'D MMMM YYYY р., LT',
86 LLLL : 'dddd, D MMMM YYYY р., LT'
87 },
88 calendar : {
89 sameDay: processHoursFunction('[Сьогодні '),
90 nextDay: processHoursFunction('[Завтра '),
91 lastDay: processHoursFunction('[Вчора '),
92 nextWeek: processHoursFunction('[У] dddd ['),
93 lastWeek: function () {
94 switch (this.day()) {
95 case 0:
96 case 3:
97 case 5:
98 case 6:
99 return processHoursFunction('[Минулої] dddd [').call(this);
100 case 1:
101 case 2:
102 case 4:
103 return processHoursFunction('[Минулого] dddd [').call(this);
104 }
105 },
106 sameElse: 'L'
107 },
108 relativeTime : {
109 future : 'за %s',
110 past : '%s тому',
111 s : 'декілька секунд',
112 m : relativeTimeWithPlural,
113 mm : relativeTimeWithPlural,
114 h : 'годину',
115 hh : relativeTimeWithPlural,
116 d : 'день',
117 dd : relativeTimeWithPlural,
118 M : 'місяць',
119 MM : relativeTimeWithPlural,
120 y : 'рік',
121 yy : relativeTimeWithPlural
122 },
123
124 // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
125
126 meridiem : function (hour, minute, isLower) {
127 if (hour < 4) {
128 return 'ночі';
129 } else if (hour < 12) {
130 return 'ранку';
131 } else if (hour < 17) {
132 return 'дня';
133 } else {
134 return 'вечора';
135 }
136 },
137
138 ordinalParse: /\d{1,2}-(й|го)/,
139 ordinal: function (number, period) {
140 switch (period) {
141 case 'M':
142 case 'd':
143 case 'DDD':
144 case 'w':
145 case 'W':
146 return number + '-й';
147 case 'D':
148 return number + '-го';
149 default:
150 return number;
151 }
152 },
153
154 week : {
155 dow : 1, // Monday is the first day of the week.
156 doy : 7 // The week that contains Jan 1st is the first week of the year.
157 }
158 });
159 }));