js âĸ Lines: 103import { numberToLocale } from "./localize.js";
const formatDistanceLocale = {
lessThanXSeconds: {
one: "āĻĒā§āϰāĻžā§ ā§§ āϏā§āĻā§āύā§āĻĄ",
other: "āĻĒā§āϰāĻžā§ {{count}} āϏā§āĻā§āύā§āĻĄ",
},
xSeconds: {
one: "ā§§ āϏā§āĻā§āύā§āĻĄ",
other: "{{count}} āϏā§āĻā§āύā§āĻĄ",
},
halfAMinute: "āĻāϧ āĻŽāĻŋāύāĻŋāĻ",
lessThanXMinutes: {
one: "āĻĒā§āϰāĻžā§ ā§§ āĻŽāĻŋāύāĻŋāĻ",
other: "āĻĒā§āϰāĻžā§ {{count}} āĻŽāĻŋāύāĻŋāĻ",
},
xMinutes: {
one: "ā§§ āĻŽāĻŋāύāĻŋāĻ",
other: "{{count}} āĻŽāĻŋāύāĻŋāĻ",
},
aboutXHours: {
one: "āĻĒā§āϰāĻžā§ ā§§ āĻāύā§āĻāĻž",
other: "āĻĒā§āϰāĻžā§ {{count}} āĻāύā§āĻāĻž",
},
xHours: {
one: "ā§§ āĻāύā§āĻāĻž",
other: "{{count}} āĻāύā§āĻāĻž",
},
xDays: {
one: "ā§§ āĻĻāĻŋāύ",
other: "{{count}} āĻĻāĻŋāύ",
},
aboutXWeeks: {
one: "āĻĒā§āϰāĻžā§ ā§§ āϏāĻĒā§āϤāĻžāĻš",
other: "āĻĒā§āϰāĻžā§ {{count}} āϏāĻĒā§āϤāĻžāĻš",
},
xWeeks: {
one: "ā§§ āϏāĻĒā§āϤāĻžāĻš",
other: "{{count}} āϏāĻĒā§āϤāĻžāĻš",
},
aboutXMonths: {
one: "āĻĒā§āϰāĻžā§ ā§§ āĻŽāĻžāϏ",
other: "āĻĒā§āϰāĻžā§ {{count}} āĻŽāĻžāϏ",
},
xMonths: {
one: "ā§§ āĻŽāĻžāϏ",
other: "{{count}} āĻŽāĻžāϏ",
},
aboutXYears: {
one: "āĻĒā§āϰāĻžā§ ā§§ āĻŦāĻāϰ",
other: "āĻĒā§āϰāĻžā§ {{count}} āĻŦāĻāϰ",
},
xYears: {
one: "ā§§ āĻŦāĻāϰ",
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}}", numberToLocale(count));
}
if (options?.addSuffix) {
if (options.comparison && options.comparison > 0) {
return result + " āĻāϰ āĻŽāϧā§āϝā§";
} else {
return result + " āĻāĻā§";
}
}
return result;
};