js β’ Lines: 101const formatDistanceLocale = {
lessThanXSeconds: {
one: "ΠΏΠΎ-ΠΌΠ°Π»ΠΊΠΎ ΠΎΡ ΡΠ΅ΠΊΡΠ½Π΄Π°",
other: "ΠΏΠΎ-ΠΌΠ°Π»ΠΊΠΎ ΠΎΡ {{count}} ΡΠ΅ΠΊΡΠ½Π΄ΠΈ",
},
xSeconds: {
one: "1 ΡΠ΅ΠΊΡΠ½Π΄Π°",
other: "{{count}} ΡΠ΅ΠΊΡΠ½Π΄ΠΈ",
},
halfAMinute: "ΠΏΠΎΠ»ΠΎΠ²ΠΈΠ½ ΠΌΠΈΠ½ΡΡΠ°",
lessThanXMinutes: {
one: "ΠΏΠΎ-ΠΌΠ°Π»ΠΊΠΎ ΠΎΡ ΠΌΠΈΠ½ΡΡΠ°",
other: "ΠΏΠΎ-ΠΌΠ°Π»ΠΊΠΎ ΠΎΡ {{count}} ΠΌΠΈΠ½ΡΡΠΈ",
},
xMinutes: {
one: "1 ΠΌΠΈΠ½ΡΡΠ°",
other: "{{count}} ΠΌΠΈΠ½ΡΡΠΈ",
},
aboutXHours: {
one: "ΠΎΠΊΠΎΠ»ΠΎ ΡΠ°Ρ",
other: "ΠΎΠΊΠΎΠ»ΠΎ {{count}} ΡΠ°ΡΠ°",
},
xHours: {
one: "1 ΡΠ°Ρ",
other: "{{count}} ΡΠ°ΡΠ°",
},
xDays: {
one: "1 Π΄Π΅Π½",
other: "{{count}} Π΄Π½ΠΈ",
},
aboutXWeeks: {
one: "ΠΎΠΊΠΎΠ»ΠΎ ΡΠ΅Π΄ΠΌΠΈΡΠ°",
other: "ΠΎΠΊΠΎΠ»ΠΎ {{count}} ΡΠ΅Π΄ΠΌΠΈΡΠΈ",
},
xWeeks: {
one: "1 ΡΠ΅Π΄ΠΌΠΈΡΠ°",
other: "{{count}} ΡΠ΅Π΄ΠΌΠΈΡΠΈ",
},
aboutXMonths: {
one: "ΠΎΠΊΠΎΠ»ΠΎ ΠΌΠ΅ΡΠ΅Ρ",
other: "ΠΎΠΊΠΎΠ»ΠΎ {{count}} ΠΌΠ΅ΡΠ΅ΡΠ°",
},
xMonths: {
one: "1 ΠΌΠ΅ΡΠ΅Ρ",
other: "{{count}} ΠΌΠ΅ΡΠ΅ΡΠ°",
},
aboutXYears: {
one: "ΠΎΠΊΠΎΠ»ΠΎ Π³ΠΎΠ΄ΠΈΠ½Π°",
other: "ΠΎΠΊΠΎΠ»ΠΎ {{count}} Π³ΠΎΠ΄ΠΈΠ½ΠΈ",
},
xYears: {
one: "1 Π³ΠΎΠ΄ΠΈΠ½Π°",
other: "{{count}} Π³ΠΎΠ΄ΠΈΠ½ΠΈ",
},
overXYears: {
one: "Π½Π°Π΄ Π³ΠΎΠ΄ΠΈΠ½Π°",
other: "Π½Π°Π΄ {{count}} Π³ΠΎΠ΄ΠΈΠ½ΠΈ",
},
almostXYears: {
one: "ΠΏΠΎΡΡΠΈ Π³ΠΎΠ΄ΠΈΠ½Π°",
other: "ΠΏΠΎΡΡΠΈ {{count}} Π³ΠΎΠ΄ΠΈΠ½ΠΈ",
},
};
export const formatDistance = (token, count, options) => {
let result;
const 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?.addSuffix) {
if (options.comparison && options.comparison > 0) {
return "ΡΠ»Π΅Π΄ " + result;
} else {
return "ΠΏΡΠ΅Π΄ΠΈ " + result;
}
}
return result;
};