master
1/*
2 *
3 * Date.addLocale(<code>) adds this locale to Sugar.
4 * To set the locale globally, simply call:
5 *
6 * Date.setLocale('ja');
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('ja', {
44 'monthSuffix': '月',
45 'weekdays': '日曜日,月曜日,火曜日,水曜日,木曜日,金曜日,土曜日',
46 'units': 'ミリ秒,秒,分,時間,日,週間|週,ヶ月|ヵ月|月,年',
47 'short': '{yyyy}年{M}月{d}日',
48 'long': '{yyyy}年{M}月{d}日 {H}時{mm}分',
49 'full': '{yyyy}年{M}月{d}日 {Weekday} {H}時{mm}分{ss}秒',
50 'past': '{num}{unit}{sign}',
51 'future': '{num}{unit}{sign}',
52 'duration': '{num}{unit}',
53 'timeSuffixes': '時,分,秒',
54 'ampm': '午前,午後',
55 'modifiers': [
56 { 'name': 'day', 'src': '一昨日', 'value': -2 },
57 { 'name': 'day', 'src': '昨日', 'value': -1 },
58 { 'name': 'day', 'src': '今日', 'value': 0 },
59 { 'name': 'day', 'src': '明日', 'value': 1 },
60 { 'name': 'day', 'src': '明後日', 'value': 2 },
61 { 'name': 'sign', 'src': '前', 'value': -1 },
62 { 'name': 'sign', 'src': '後', 'value': 1 },
63 { 'name': 'shift', 'src': '去|先', 'value': -1 },
64 { 'name': 'shift', 'src': '来', 'value': 1 }
65 ],
66 'dateParse': [
67 '{num}{unit}{sign}'
68 ],
69 'timeParse': [
70 '{shift}{unit=5-7}{weekday?}',
71 '{year}年{month?}月?{date?}日?',
72 '{month}月{date?}日?',
73 '{date}日'
74 ]
75});
76