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

const formatDistanceLocale = {
  lessThanXSeconds: {
    one: "1びょうみまん",
    other: "{{count}}びょうみまん",
    oneWithSuffix: "やく1びょう",
    otherWithSuffix: "やく{{count}}びょう",
  },

  xSeconds: {
    one: "1びょう",
    other: "{{count}}びょう",
  },

  halfAMinute: "30びょう",

  lessThanXMinutes: {
    one: "1ぷんみまん",
    other: "{{count}}ちんみまん",
    oneWithSuffix: "やく1ぷん",
    otherWithSuffix: "やく{{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}}ねんけかく",
  },
};

const formatDistance = (token, count, options) => {
  options = options || {};

  let result;

  const tokenValue = formatDistanceLocale[token];
  if (typeof tokenValue === "string") {
    result = tokenValue;
  } else if (count === 1) {
    if (options.addSuffix && tokenValue.oneWithSuffix) {
      result = tokenValue.oneWithSuffix;
    } else {
      result = tokenValue.one;
    }
  } else {
    if (options.addSuffix && tokenValue.otherWithSuffix) {
      result = tokenValue.otherWithSuffix.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;