πŸ“„ formatDistance.cjs
/home/palash/git/site/node_modules/date-fns/locale/sr/_lib/formatDistance.cjs
Language: cjs β€’ Lines: 194
"use strict";
exports.formatDistance = void 0;

const formatDistanceLocale = {
  lessThanXSeconds: {
    one: {
      standalone: "мањС ΠΎΠ΄ 1 сСкундС",
      withPrepositionAgo: "мањС ΠΎΠ΄ 1 сСкундС",
      withPrepositionIn: "мањС ΠΎΠ΄ 1 сСкунду",
    },
    dual: "мањС ΠΎΠ΄ {{count}} сСкундС",
    other: "мањС ΠΎΠ΄ {{count}} сСкунди",
  },

  xSeconds: {
    one: {
      standalone: "1 сСкунда",
      withPrepositionAgo: "1 сСкундС",
      withPrepositionIn: "1 сСкунду",
    },
    dual: "{{count}} сСкундС",
    other: "{{count}} сСкунди",
  },

  halfAMinute: "ΠΏΠΎΠ»Π° ΠΌΠΈΠ½ΡƒΡ‚Π΅",

  lessThanXMinutes: {
    one: {
      standalone: "мањС ΠΎΠ΄ 1 ΠΌΠΈΠ½ΡƒΡ‚Π΅",
      withPrepositionAgo: "мањС ΠΎΠ΄ 1 ΠΌΠΈΠ½ΡƒΡ‚Π΅",
      withPrepositionIn: "мањС ΠΎΠ΄ 1 ΠΌΠΈΠ½ΡƒΡ‚Ρƒ",
    },
    dual: "мањС ΠΎΠ΄ {{count}} ΠΌΠΈΠ½ΡƒΡ‚Π΅",
    other: "мањС ΠΎΠ΄ {{count}} ΠΌΠΈΠ½ΡƒΡ‚Π°",
  },

  xMinutes: {
    one: {
      standalone: "1 ΠΌΠΈΠ½ΡƒΡ‚Π°",
      withPrepositionAgo: "1 ΠΌΠΈΠ½ΡƒΡ‚Π΅",
      withPrepositionIn: "1 ΠΌΠΈΠ½ΡƒΡ‚Ρƒ",
    },
    dual: "{{count}} ΠΌΠΈΠ½ΡƒΡ‚Π΅",
    other: "{{count}} ΠΌΠΈΠ½ΡƒΡ‚Π°",
  },

  aboutXHours: {
    one: {
      standalone: "ΠΎΠΊΠΎ 1 сат",
      withPrepositionAgo: "ΠΎΠΊΠΎ 1 сат",
      withPrepositionIn: "ΠΎΠΊΠΎ 1 сат",
    },
    dual: "ΠΎΠΊΠΎ {{count}} сата",
    other: "ΠΎΠΊΠΎ {{count}} сати",
  },

  xHours: {
    one: {
      standalone: "1 сат",
      withPrepositionAgo: "1 сат",
      withPrepositionIn: "1 сат",
    },
    dual: "{{count}} сата",
    other: "{{count}} сати",
  },

  xDays: {
    one: {
      standalone: "1 Π΄Π°Π½",
      withPrepositionAgo: "1 Π΄Π°Π½",
      withPrepositionIn: "1 Π΄Π°Π½",
    },
    dual: "{{count}} Π΄Π°Π½Π°",
    other: "{{count}} Π΄Π°Π½Π°",
  },

  aboutXWeeks: {
    one: {
      standalone: "ΠΎΠΊΠΎ 1 Π½Π΅Π΄Π΅Ρ™Ρƒ",
      withPrepositionAgo: "ΠΎΠΊΠΎ 1 Π½Π΅Π΄Π΅Ρ™Ρƒ",
      withPrepositionIn: "ΠΎΠΊΠΎ 1 Π½Π΅Π΄Π΅Ρ™Ρƒ",
    },
    dual: "ΠΎΠΊΠΎ {{count}} Π½Π΅Π΄Π΅Ρ™Π΅",
    other: "ΠΎΠΊΠΎ {{count}} Π½Π΅Π΄Π΅Ρ™Π΅",
  },

  xWeeks: {
    one: {
      standalone: "1 Π½Π΅Π΄Π΅Ρ™Ρƒ",
      withPrepositionAgo: "1 Π½Π΅Π΄Π΅Ρ™Ρƒ",
      withPrepositionIn: "1 Π½Π΅Π΄Π΅Ρ™Ρƒ",
    },
    dual: "{{count}} Π½Π΅Π΄Π΅Ρ™Π΅",
    other: "{{count}} Π½Π΅Π΄Π΅Ρ™Π΅",
  },

  aboutXMonths: {
    one: {
      standalone: "ΠΎΠΊΠΎ 1 мСсСц",
      withPrepositionAgo: "ΠΎΠΊΠΎ 1 мСсСц",
      withPrepositionIn: "ΠΎΠΊΠΎ 1 мСсСц",
    },
    dual: "ΠΎΠΊΠΎ {{count}} мСсСца",
    other: "ΠΎΠΊΠΎ {{count}} мСсСци",
  },

  xMonths: {
    one: {
      standalone: "1 мСсСц",
      withPrepositionAgo: "1 мСсСц",
      withPrepositionIn: "1 мСсСц",
    },
    dual: "{{count}} мСсСца",
    other: "{{count}} мСсСци",
  },

  aboutXYears: {
    one: {
      standalone: "ΠΎΠΊΠΎ 1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
      withPrepositionAgo: "ΠΎΠΊΠΎ 1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
      withPrepositionIn: "ΠΎΠΊΠΎ 1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
    },
    dual: "ΠΎΠΊΠΎ {{count}} Π³ΠΎΠ΄ΠΈΠ½Π΅",
    other: "ΠΎΠΊΠΎ {{count}} Π³ΠΎΠ΄ΠΈΠ½Π°",
  },

  xYears: {
    one: {
      standalone: "1 Π³ΠΎΠ΄ΠΈΠ½Π°",
      withPrepositionAgo: "1 Π³ΠΎΠ΄ΠΈΠ½Π΅",
      withPrepositionIn: "1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
    },
    dual: "{{count}} Π³ΠΎΠ΄ΠΈΠ½Π΅",
    other: "{{count}} Π³ΠΎΠ΄ΠΈΠ½Π°",
  },

  overXYears: {
    one: {
      standalone: "ΠΏΡ€Π΅ΠΊΠΎ 1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
      withPrepositionAgo: "ΠΏΡ€Π΅ΠΊΠΎ 1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
      withPrepositionIn: "ΠΏΡ€Π΅ΠΊΠΎ 1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
    },
    dual: "ΠΏΡ€Π΅ΠΊΠΎ {{count}} Π³ΠΎΠ΄ΠΈΠ½Π΅",
    other: "ΠΏΡ€Π΅ΠΊΠΎ {{count}} Π³ΠΎΠ΄ΠΈΠ½Π°",
  },

  almostXYears: {
    one: {
      standalone: "Π³ΠΎΡ‚ΠΎΠ²ΠΎ 1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
      withPrepositionAgo: "Π³ΠΎΡ‚ΠΎΠ²ΠΎ 1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
      withPrepositionIn: "Π³ΠΎΡ‚ΠΎΠ²ΠΎ 1 Π³ΠΎΠ΄ΠΈΠ½Ρƒ",
    },
    dual: "Π³ΠΎΡ‚ΠΎΠ²ΠΎ {{count}} Π³ΠΎΠ΄ΠΈΠ½Π΅",
    other: "Π³ΠΎΡ‚ΠΎΠ²ΠΎ {{count}} Π³ΠΎΠ΄ΠΈΠ½Π°",
  },
};

const formatDistance = (token, count, options) => {
  let result;

  const tokenValue = formatDistanceLocale[token];
  if (typeof tokenValue === "string") {
    result = tokenValue;
  } else if (count === 1) {
    if (options?.addSuffix) {
      if (options.comparison && options.comparison > 0) {
        result = tokenValue.one.withPrepositionIn;
      } else {
        result = tokenValue.one.withPrepositionAgo;
      }
    } else {
      result = tokenValue.one.standalone;
    }
  } else if (
    count % 10 > 1 &&
    count % 10 < 5 && // if last digit is between 2 and 4
    String(count).substr(-2, 1) !== "1" // unless the 2nd to last digit is "1"
  ) {
    result = tokenValue.dual.replace("{{count}}", String(count));
  } else {
    result = tokenValue.other.replace("{{count}}", String(count));
  }

  if (options?.addSuffix) {
    if (options.comparison && options.comparison > 0) {
      return "Π·Π° " + result;
    } else {
      return "ΠΏΡ€Π΅ " + result;
    }
  }

  return result;
};
exports.formatDistance = formatDistance;