codigo0/node_modules/date-fns/locale/sr-Latn/_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

191 lines
4.3 KiB
JavaScript

const formatDistanceLocale = {
lessThanXSeconds: {
one: {
standalone: "manje od 1 sekunde",
withPrepositionAgo: "manje od 1 sekunde",
withPrepositionIn: "manje od 1 sekundu",
},
dual: "manje od {{count}} sekunde",
other: "manje od {{count}} sekundi",
},
xSeconds: {
one: {
standalone: "1 sekunda",
withPrepositionAgo: "1 sekunde",
withPrepositionIn: "1 sekundu",
},
dual: "{{count}} sekunde",
other: "{{count}} sekundi",
},
halfAMinute: "pola minute",
lessThanXMinutes: {
one: {
standalone: "manje od 1 minute",
withPrepositionAgo: "manje od 1 minute",
withPrepositionIn: "manje od 1 minutu",
},
dual: "manje od {{count}} minute",
other: "manje od {{count}} minuta",
},
xMinutes: {
one: {
standalone: "1 minuta",
withPrepositionAgo: "1 minute",
withPrepositionIn: "1 minutu",
},
dual: "{{count}} minute",
other: "{{count}} minuta",
},
aboutXHours: {
one: {
standalone: "oko 1 sat",
withPrepositionAgo: "oko 1 sat",
withPrepositionIn: "oko 1 sat",
},
dual: "oko {{count}} sata",
other: "oko {{count}} sati",
},
xHours: {
one: {
standalone: "1 sat",
withPrepositionAgo: "1 sat",
withPrepositionIn: "1 sat",
},
dual: "{{count}} sata",
other: "{{count}} sati",
},
xDays: {
one: {
standalone: "1 dan",
withPrepositionAgo: "1 dan",
withPrepositionIn: "1 dan",
},
dual: "{{count}} dana",
other: "{{count}} dana",
},
aboutXWeeks: {
one: {
standalone: "oko 1 nedelju",
withPrepositionAgo: "oko 1 nedelju",
withPrepositionIn: "oko 1 nedelju",
},
dual: "oko {{count}} nedelje",
other: "oko {{count}} nedelje",
},
xWeeks: {
one: {
standalone: "1 nedelju",
withPrepositionAgo: "1 nedelju",
withPrepositionIn: "1 nedelju",
},
dual: "{{count}} nedelje",
other: "{{count}} nedelje",
},
aboutXMonths: {
one: {
standalone: "oko 1 mesec",
withPrepositionAgo: "oko 1 mesec",
withPrepositionIn: "oko 1 mesec",
},
dual: "oko {{count}} meseca",
other: "oko {{count}} meseci",
},
xMonths: {
one: {
standalone: "1 mesec",
withPrepositionAgo: "1 mesec",
withPrepositionIn: "1 mesec",
},
dual: "{{count}} meseca",
other: "{{count}} meseci",
},
aboutXYears: {
one: {
standalone: "oko 1 godinu",
withPrepositionAgo: "oko 1 godinu",
withPrepositionIn: "oko 1 godinu",
},
dual: "oko {{count}} godine",
other: "oko {{count}} godina",
},
xYears: {
one: {
standalone: "1 godina",
withPrepositionAgo: "1 godine",
withPrepositionIn: "1 godinu",
},
dual: "{{count}} godine",
other: "{{count}} godina",
},
overXYears: {
one: {
standalone: "preko 1 godinu",
withPrepositionAgo: "preko 1 godinu",
withPrepositionIn: "preko 1 godinu",
},
dual: "preko {{count}} godine",
other: "preko {{count}} godina",
},
almostXYears: {
one: {
standalone: "gotovo 1 godinu",
withPrepositionAgo: "gotovo 1 godinu",
withPrepositionIn: "gotovo 1 godinu",
},
dual: "gotovo {{count}} godine",
other: "gotovo {{count}} godina",
},
};
export 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 "za " + result;
} else {
return "pre " + result;
}
}
return result;
};