js β’ Lines: 101const formatDistanceLocale = {
lessThanXSeconds: {
one: "1μ΄ λ―Έλ§",
other: "{{count}}μ΄ λ―Έλ§",
},
xSeconds: {
one: "1μ΄",
other: "{{count}}μ΄",
},
halfAMinute: "30μ΄",
lessThanXMinutes: {
one: "1λΆ λ―Έλ§",
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}}λ
",
},
};
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}}", count.toString());
}
if (options?.addSuffix) {
if (options.comparison && options.comparison > 0) {
return result + " ν";
} else {
return result + " μ ";
}
}
return result;
};