This repository has been archived by the owner on Mar 22, 2022. It is now read-only.
/
index.js
318 lines (291 loc) · 7.21 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
var formatDistanceLocale = {
lessThanXSeconds: {
one: {
regular: 'méně než vteřina',
past: 'před méně než vteřinou',
future: 'za méně než vteřinu'
},
few: {
regular: 'méně než {{count}} vteřiny',
past: 'před méně než {{count}} vteřinami',
future: 'za méně než {{count}} vteřiny'
},
many: {
regular: 'méně než {{count}} vteřin',
past: 'před méně než {{count}} vteřinami',
future: 'za méně než {{count}} vteřin'
}
},
xSeconds: {
one: {
regular: 'vteřina',
past: 'před vteřinou',
future: 'za vteřinu'
},
few: {
regular: '{{count}} vteřiny',
past: 'před {{count}} vteřinami',
future: 'za {{count}} vteřiny'
},
many: {
regular: '{{count}} vteřin',
past: 'před {{count}} vteřinami',
future: 'za {{count}} vteřin'
}
},
halfAMinute: {
other: {
regular: 'půl minuty',
past: 'před půl minutou',
future: 'za půl minuty'
}
},
lessThanXMinutes: {
one: {
regular: 'méně než minuta',
past: 'před méně než minutou',
future: 'za méně než minutu'
},
few: {
regular: 'méně než {{count}} minuty',
past: 'před méně než {{count}} minutami',
future: 'za méně než {{count}} minuty'
},
many: {
regular: 'méně než {{count}} minut',
past: 'před méně než {{count}} minutami',
future: 'za méně než {{count}} minut'
}
},
xMinutes: {
one: {
regular: 'minuta',
past: 'před minutou',
future: 'za minutu'
},
few: {
regular: '{{count}} minuty',
past: 'před {{count}} minutami',
future: 'za {{count}} minuty'
},
many: {
regular: '{{count}} minut',
past: 'před {{count}} minutami',
future: 'za {{count}} minut'
}
},
aboutXHours: {
one: {
regular: 'přibližně hodina',
past: 'přibližně před hodinou',
future: 'přibližně za hodinu'
},
few: {
regular: 'přibližně {{count}} hodiny',
past: 'přibližně před {{count}} hodinami',
future: 'přibližně za {{count}} hodiny'
},
many: {
regular: 'přibližně {{count}} hodin',
past: 'přibližně před {{count}} hodinami',
future: 'přibližně za {{count}} hodin'
}
},
xHours: {
one: {
regular: 'hodina',
past: 'před hodinou',
future: 'za hodinu'
},
few: {
regular: '{{count}} hodiny',
past: 'před {{count}} hodinami',
future: 'za {{count}} hodiny'
},
many: {
regular: '{{count}} hodin',
past: 'před {{count}} hodinami',
future: 'za {{count}} hodin'
}
},
xDays: {
one: {
regular: 'den',
past: 'před dnem',
future: 'za den'
},
few: {
regular: '{{count}} dny',
past: 'před {{count}} dny',
future: 'za {{count}} dny'
},
many: {
regular: '{{count}} dní',
past: 'před {{count}} dny',
future: 'za {{count}} dní'
}
},
aboutXWeeks: {
one: {
regular: 'přibližně týden',
past: 'přibližně před týdnem',
future: 'přibližně za týden'
},
few: {
regular: 'přibližně {{count}} týdny',
past: 'přibližně před {{count}} týdny',
future: 'přibližně za {{count}} týdny'
},
many: {
regular: 'přibližně {{count}} týdnů',
past: 'přibližně před {{count}} týdny',
future: 'přibližně za {{count}} týdnů'
}
},
xWeeks: {
one: {
regular: 'týden',
past: 'před týdnem',
future: 'za týden'
},
few: {
regular: '{{count}} týdny',
past: 'před {{count}} týdny',
future: 'za {{count}} týdny'
},
many: {
regular: '{{count}} týdnů',
past: 'před {{count}} týdny',
future: 'za {{count}} týdnů'
}
},
aboutXMonths: {
one: {
regular: 'přibližně měsíc',
past: 'přibližně před měsícem',
future: 'přibližně za měsíc'
},
few: {
regular: 'přibližně {{count}} měsíce',
past: 'přibližně před {{count}} měsíci',
future: 'přibližně za {{count}} měsíce'
},
many: {
regular: 'přibližně {{count}} měsíců',
past: 'přibližně před {{count}} měsíci',
future: 'přibližně za {{count}} měsíců'
}
},
xMonths: {
one: {
regular: 'měsíc',
past: 'před měsícem',
future: 'za měsíc'
},
few: {
regular: '{{count}} měsíce',
past: 'před {{count}} měsíci',
future: 'za {{count}} měsíce'
},
many: {
regular: '{{count}} měsíců',
past: 'před {{count}} měsíci',
future: 'za {{count}} měsíců'
}
},
aboutXYears: {
one: {
regular: 'přibližně rok',
past: 'přibližně před rokem',
future: 'přibližně za rok'
},
few: {
regular: 'přibližně {{count}} roky',
past: 'přibližně před {{count}} roky',
future: 'přibližně za {{count}} roky'
},
many: {
regular: 'přibližně {{count}} roků',
past: 'přibližně před {{count}} roky',
future: 'přibližně za {{count}} roků'
}
},
xYears: {
one: {
regular: 'rok',
past: 'před rokem',
future: 'za rok'
},
few: {
regular: '{{count}} roky',
past: 'před {{count}} roky',
future: 'za {{count}} roky'
},
many: {
regular: '{{count}} roků',
past: 'před {{count}} roky',
future: 'za {{count}} roků'
}
},
overXYears: {
one: {
regular: 'více než rok',
past: 'před více než rokem',
future: 'za více než rok'
},
few: {
regular: 'více než {{count}} roky',
past: 'před více než {{count}} roky',
future: 'za více než {{count}} roky'
},
many: {
regular: 'více než {{count}} roků',
past: 'před více než {{count}} roky',
future: 'za více než {{count}} roků'
}
},
almostXYears: {
one: {
regular: 'skoro rok',
past: 'skoro před rokem',
future: 'skoro za rok'
},
few: {
regular: 'skoro {{count}} roky',
past: 'skoro před {{count}} roky',
future: 'skoro za {{count}} roky'
},
many: {
regular: 'skoro {{count}} roků',
past: 'skoro před {{count}} roky',
future: 'skoro za {{count}} roků'
}
}
}
export default function formatDistance(token, count, options) {
options = options || {}
var scheme = formatDistanceLocale[token]
// cs pluralization
var pluralToken
if (typeof scheme.other === 'object') {
pluralToken = 'other'
} else if (count === 1) {
pluralToken = 'one'
} else if ((count > 1 && count < 5) || count === 0) {
pluralToken = 'few'
} else {
pluralToken = 'many'
}
// times
var suffixExist = options.addSuffix === true
var comparison = options.comparison
var timeToken
if (suffixExist && comparison === -1) {
timeToken = 'past'
} else if (suffixExist && comparison === 1) {
timeToken = 'future'
} else {
timeToken = 'regular'
}
return scheme[pluralToken][timeToken].replace('{{count}}', count)
}