recoder-code
Version:
π AI-powered development platform - Chat with 32+ models, build projects, automate workflows. Free models included!
83 lines β’ 2.14 kB
JavaScript
var formatDistanceLocale = {
lessThanXSeconds: {
one: 'ΠΏΠΎΠΌΠ°Π»ΠΊΡ ΠΎΠ΄ ΡΠ΅ΠΊΡΠ½Π΄Π°',
other: 'ΠΏΠΎΠΌΠ°Π»ΠΊΡ ΠΎΠ΄ {{count}} ΡΠ΅ΠΊΡΠ½Π΄ΠΈ'
},
xSeconds: {
one: '1 ΡΠ΅ΠΊΡΠ½Π΄Π°',
other: '{{count}} ΡΠ΅ΠΊΡΠ½Π΄ΠΈ'
},
halfAMinute: 'ΠΏΠΎΠ»ΠΎΠ²ΠΈΠ½Π° ΠΌΠΈΠ½ΡΡΠ°',
lessThanXMinutes: {
one: 'ΠΏΠΎΠΌΠ°Π»ΠΊΡ ΠΎΠ΄ ΠΌΠΈΠ½ΡΡΠ°',
other: 'ΠΏΠΎΠΌΠ°Π»ΠΊΡ ΠΎΠ΄ {{count}} ΠΌΠΈΠ½ΡΡΠΈ'
},
xMinutes: {
one: '1 ΠΌΠΈΠ½ΡΡΠ°',
other: '{{count}} ΠΌΠΈΠ½ΡΡΠΈ'
},
aboutXHours: {
one: 'ΠΎΠΊΠΎΠ»Ρ 1 ΡΠ°Ρ',
other: 'ΠΎΠΊΠΎΠ»Ρ {{count}} ΡΠ°ΡΠ°'
},
xHours: {
one: '1 ΡΠ°Ρ',
other: '{{count}} ΡΠ°ΡΠ°'
},
xDays: {
one: '1 Π΄Π΅Π½',
other: '{{count}} Π΄Π΅Π½Π°'
},
aboutXWeeks: {
one: 'ΠΎΠΊΠΎΠ»Ρ 1 Π½Π΅Π΄Π΅Π»Π°',
other: 'ΠΎΠΊΠΎΠ»Ρ {{count}} ΠΌΠ΅ΡΠ΅ΡΠΈ'
},
xWeeks: {
one: '1 Π½Π΅Π΄Π΅Π»Π°',
other: '{{count}} Π½Π΅Π΄Π΅Π»ΠΈ'
},
aboutXMonths: {
one: 'ΠΎΠΊΠΎΠ»Ρ 1 ΠΌΠ΅ΡΠ΅Ρ',
other: 'ΠΎΠΊΠΎΠ»Ρ {{count}} Π½Π΅Π΄Π΅Π»ΠΈ'
},
xMonths: {
one: '1 ΠΌΠ΅ΡΠ΅Ρ',
other: '{{count}} ΠΌΠ΅ΡΠ΅ΡΠΈ'
},
aboutXYears: {
one: 'ΠΎΠΊΠΎΠ»Ρ 1 Π³ΠΎΠ΄ΠΈΠ½Π°',
other: 'ΠΎΠΊΠΎΠ»Ρ {{count}} Π³ΠΎΠ΄ΠΈΠ½ΠΈ'
},
xYears: {
one: '1 Π³ΠΎΠ΄ΠΈΠ½Π°',
other: '{{count}} Π³ΠΎΠ΄ΠΈΠ½ΠΈ'
},
overXYears: {
one: 'ΠΏΠΎΠ²Π΅ΡΠ΅ ΠΎΠ΄ 1 Π³ΠΎΠ΄ΠΈΠ½Π°',
other: 'ΠΏΠΎΠ²Π΅ΡΠ΅ ΠΎΠ΄ {{count}} Π³ΠΎΠ΄ΠΈΠ½ΠΈ'
},
almostXYears: {
one: 'Π±Π΅Π·ΠΌΠ°Π»ΠΊΡ 1 Π³ΠΎΠ΄ΠΈΠ½Π°',
other: 'Π±Π΅Π·ΠΌΠ°Π»ΠΊΡ {{count}} Π³ΠΎΠ΄ΠΈΠ½ΠΈ'
}
};
var formatDistance = function formatDistance(token, count, options) {
var result;
var tokenValue = formatDistanceLocale[token];
if (typeof tokenValue === 'string') {
result = tokenValue;
} else if (count === 1) {
result = tokenValue.one;
} else {
result = tokenValue.other.replace('{{count}}', String(count));
}
if (options !== null && options !== void 0 && options.addSuffix) {
if (options.comparison && options.comparison > 0) {
return 'Π·Π° ' + result;
} else {
return 'ΠΏΡΠ΅Π΄ ' + result;
}
}
return result;
};
export default formatDistance;