master
1/*
2 *
3 * Date.addLocale(<code>) adds this locale to Sugar.
4 * To set the locale globally, simply call:
5 *
6 * Date.setLocale('ru');
7 *
8 * var locale = Date.getLocale(<code>) will return this object, which
9 * can be tweaked to change the behavior of parsing/formatting in the locales.
10 *
11 * locale.addFormat adds a date format (see this file for examples).
12 * Special tokens in the date format will be parsed out into regex tokens:
13 *
14 * {0} is a reference to an entry in locale.tokens. Output: (?:the)?
15 * {unit} is a reference to all units. Output: (day|week|month|...)
16 * {unit3} is a reference to a specific unit. Output: (hour)
17 * {unit3-5} is a reference to a subset of the units array. Output: (hour|day|week)
18 * {unit?} "?" makes that token optional. Output: (day|week|month)?
19 *
20 * {day} Any reference to tokens in the modifiers array will include all with the same name. Output: (yesterday|today|tomorrow)
21 *
22 * All spaces are optional and will be converted to "\s*"
23 *
24 * Locale arrays months, weekdays, units, numbers, as well as the "src" field for
25 * all entries in the modifiers array follow a special format indicated by a colon:
26 *
27 * minute:|s = minute|minutes
28 * thicke:n|r = thicken|thicker
29 *
30 * Additionally in the months, weekdays, units, and numbers array these will be added at indexes that are multiples
31 * of the relevant number for retrieval. For example having "sunday:|s" in the units array will result in:
32 *
33 * units: ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sundays']
34 *
35 * When matched, the index will be found using:
36 *
37 * units.indexOf(match) % 7;
38 *
39 * Resulting in the correct index with any number of alternates for that entry.
40 *
41 */
42
43Date.addLocale('ru', {
44 'months': 'Январ:я|ь,Феврал:я|ь,Март:а|,Апрел:я|ь,Ма:я|й,Июн:я|ь,Июл:я|ь,Август:а|,Сентябр:я|ь,Октябр:я|ь,Ноябр:я|ь,Декабр:я|ь',
45 'weekdays': 'Воскресенье,Понедельник,Вторник,Среда,Четверг,Пятница,Суббота',
46 'units': 'миллисекунд:а|у|ы|,секунд:а|у|ы|,минут:а|у|ы|,час:||а|ов,день|день|дня|дней,недел:я|ю|и|ь|е,месяц:||а|ев|е,год|год|года|лет|году',
47 'numbers': 'од:ин|ну,дв:а|е,три,четыре,пять,шесть,семь,восемь,девять,десять',
48 'tokens': 'в|на,года',
49 'short':'{d} {month} {yyyy} года',
50 'long': '{d} {month} {yyyy} года {H}:{mm}',
51 'full': '{Weekday} {d} {month} {yyyy} года {H}:{mm}:{ss}',
52 'relative': function(num, unit, ms, format) {
53 var numberWithUnit, last = num.toString().slice(-1), mult;
54 switch(true) {
55 case num >= 11 && num <= 15: mult = 3; break;
56 case last == 1: mult = 1; break;
57 case last >= 2 && last <= 4: mult = 2; break;
58 default: mult = 3;
59 }
60 numberWithUnit = num + ' ' + this['units'][(mult * 8) + unit];
61 switch(format) {
62 case 'duration': return numberWithUnit;
63 case 'past': return numberWithUnit + ' назад';
64 case 'future': return 'через ' + numberWithUnit;
65 }
66 },
67 'timeMarker': 'в',
68 'ampm': ' утра, вечера',
69 'modifiers': [
70 { 'name': 'day', 'src': 'позавчера', 'value': -2 },
71 { 'name': 'day', 'src': 'вчера', 'value': -1 },
72 { 'name': 'day', 'src': 'сегодня', 'value': 0 },
73 { 'name': 'day', 'src': 'завтра', 'value': 1 },
74 { 'name': 'day', 'src': 'послезавтра', 'value': 2 },
75 { 'name': 'sign', 'src': 'назад', 'value': -1 },
76 { 'name': 'sign', 'src': 'через', 'value': 1 },
77 { 'name': 'shift', 'src': 'прошл:ый|ой|ом', 'value': -1 },
78 { 'name': 'shift', 'src': 'следующ:ий|ей|ем', 'value': 1 }
79 ],
80 'dateParse': [
81 '{num} {unit} {sign}',
82 '{sign} {num} {unit}',
83 '{month} {year}',
84 '{0?} {shift} {unit=5-7}'
85 ],
86 'timeParse': [
87 '{date} {month} {year?} {1?}',
88 '{0?} {shift} {weekday}'
89 ]
90});
91