| 87 | }; |
| 88 | |
| 89 | export const formatDistance: FormatDistanceFn = (token, count, options) => { |
| 90 | let result; |
| 91 | |
| 92 | const tokenValue = formatDistanceLocale[token]; |
| 93 | if (typeof tokenValue === "string") { |
| 94 | result = tokenValue; |
| 95 | } else if (count === 1) { |
| 96 | result = tokenValue.one; |
| 97 | } else { |
| 98 | result = tokenValue.other.replace("{{count}}", count.toString()); |
| 99 | } |
| 100 | |
| 101 | if (options?.addSuffix) { |
| 102 | if (options.comparison && options.comparison > 0) { |
| 103 | return result + " 후"; |
| 104 | } else { |
| 105 | return result + " 전"; |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | return result; |
| 110 | }; |