codigo0/node_modules/date-fns/locale/ja-Hira/_lib/formatDistance.mjs
planetazuzu 5d7a6500fe refactor: Fase 1 - Clean Architecture, refactorización modular y eliminación de duplicidades
-  Ticket 1.1: Estructura Clean Architecture en backend
-  Ticket 1.2: Schemas Zod compartidos
-  Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares)
-  Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares)
-  Ticket 1.5: Eliminación de duplicidades (~50 líneas)

Cambios principales:
- Creada estructura Clean Architecture en backend/src/
- Schemas Zod compartidos en backend/src/shared/schemas/
- Refactorización modular de drugs y procedures
- Utilidades genéricas en src/utils/ (filter, validation)
- Eliminados scripts obsoletos y documentación antigua
- Corregidos errores: QueryClient, import test-error-handling
- Build verificado y funcionando correctamente
2026-01-25 21:09:47 +01:00

116 lines
2.3 KiB
JavaScript

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}}ねんちかく",
},
};
export 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;
};