codigo0/node_modules/date-fns/parse/_lib/parsers/StandAloneLocalDayParser.js
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

103 lines
2.5 KiB
JavaScript

"use strict";
exports.StandAloneLocalDayParser = void 0;
var _index = require("../../../setDay.js");
var _Parser = require("../Parser.js");
var _utils = require("../utils.js");
// Stand-alone local day of week
class StandAloneLocalDayParser extends _Parser.Parser {
priority = 90;
parse(dateString, token, match, options) {
const valueCallback = (value) => {
// We want here floor instead of trunc, so we get -7 for value 0 instead of 0
const wholeWeekDays = Math.floor((value - 1) / 7) * 7;
return ((value + options.weekStartsOn + 6) % 7) + wholeWeekDays;
};
switch (token) {
// 3
case "c":
case "cc": // 03
return (0, _utils.mapValue)(
(0, _utils.parseNDigits)(token.length, dateString),
valueCallback,
);
// 3rd
case "co":
return (0, _utils.mapValue)(
match.ordinalNumber(dateString, {
unit: "day",
}),
valueCallback,
);
// Tue
case "ccc":
return (
match.day(dateString, {
width: "abbreviated",
context: "standalone",
}) ||
match.day(dateString, { width: "short", context: "standalone" }) ||
match.day(dateString, { width: "narrow", context: "standalone" })
);
// T
case "ccccc":
return match.day(dateString, {
width: "narrow",
context: "standalone",
});
// Tu
case "cccccc":
return (
match.day(dateString, { width: "short", context: "standalone" }) ||
match.day(dateString, { width: "narrow", context: "standalone" })
);
// Tuesday
case "cccc":
default:
return (
match.day(dateString, { width: "wide", context: "standalone" }) ||
match.day(dateString, {
width: "abbreviated",
context: "standalone",
}) ||
match.day(dateString, { width: "short", context: "standalone" }) ||
match.day(dateString, { width: "narrow", context: "standalone" })
);
}
}
validate(_date, value) {
return value >= 0 && value <= 6;
}
set(date, _flags, value, options) {
date = (0, _index.setDay)(date, value, options);
date.setHours(0, 0, 0, 0);
return date;
}
incompatibleTokens = [
"y",
"R",
"u",
"q",
"Q",
"M",
"L",
"I",
"d",
"D",
"E",
"i",
"e",
"t",
"T",
];
}
exports.StandAloneLocalDayParser = StandAloneLocalDayParser;