forked from date-fns/date-fns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
51 lines (33 loc) · 1.05 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
import utils from '../utils.js'
var formatDistanceLocale = {
lessThanXSeconds: 'کمتر از {{count}} ثانیه',
xSeconds: '{{count}} ثانیه',
halfAMinute: 'نیم دقیقه',
lessThanXMinutes: 'کمتر از {{count}} دقیقه',
xMinutes: '{{count}} دقیقه',
aboutXHours: 'نزدیک به {{count}} ساعت',
xHours: '{{count}} ساعت',
xDays: '{{count}} روز',
aboutXMonths: 'نزدیک به {{count}} ماه',
xMonths: '{{count}} ماه',
aboutXYears: 'نزدیک به {{count}} سال',
xYears: '{{count}} سال',
overXYears: 'بیش از {{count}} سال',
almostXYears: 'نزدیک به {{count}} سال'
}
export default function formatDistance(token, count, options) {
options = options || {}
var result
result = formatDistanceLocale[token].replace(
'{{count}}',
Number.isInteger(count) ? utils.eng2per(count) : ''
)
if (options.addSuffix) {
if (options.comparison > 0) {
return 'در ' + result
} else {
return result + ' پیش'
}
}
return result
}