El editor dejaba la fecha clavada en hoy, asi que al escribir 05:30 siendo
las 18:30 el candidato quedaba en el pasado, `calcularProxima` lo rechazaba
con razon y la alarma se guardaba sin proxima ejecucion: nunca sonaba. En la
practica solo se podian poner alarmas unicas para lo que quedaba de dia.
`normalizarFechaUnica` resuelve el dia que el usuario realmente quiere, con
la convencion de cualquier despertador: hora ya pasada -> manana, hora por
llegar -> hoy. Una fecha elegida a proposito en el futuro no se toca nunca,
y una fecha rancia salta a hoy/manana en vez de a `fecha + 1`, que seguiria
en el pasado.
La regla vive en el editor y NO dentro de `calcularProxima`: esa tiene que
seguir siendo literal, porque el recalculo posterior al disparo y el motor
nativo dependen de que una alarma unica vencida resuelva a null en vez de
resucitar al dia siguiente.
De paso el editor pasa a leer el reloj inyectado del servicio en vez de
`DateTime.now()`, para que la vista previa, los limites del selector de
fecha y el ajuste lean el mismo instante y se puedan fijar en las pruebas.
ExcepcionAlarma._esValida matched ANY exception tipo against an
occurrence, treating it as a user skip. Only the 'skipNext' tipo
existed until now, but the next commits reuse the same model to
record scheduling-reliability failures per alarm (so the alarms list
can surface them via ultimaExcepcionPara) -- without this guard, a
recorded failure would be silently treated as if the user asked to
skip that occurrence, corrupting scheduling. Adds tipo constants to
ExcepcionAlarma for the upcoming failure kinds.
Full time-domain audit (three shipped date bugs prompted it) found one
root cause and two latent travel defects, all now fixed:
Day-stepping used add(Duration(days: 1)), which shifts the absolute
instant by exactly 86400s — documented Dart behavior (sdk#47666), so
crossing a DST transition drifted the wall hour by +-1h permanently
for the rest of the candidate scan (verified: 2026-03-28 07:30
Europe/Madrid + "1 day" = 08:30). The native Calendar engine preserves
wall time, and the single-authority fix made the drifted Dart verdict
win. Candidates now advance by calendar reconstruction (_siguienteDia:
DateTime(y, m, d+1, hora, minuto)), the same wall-clock-preserving
semantics as Calendar.add(DAY_OF_YEAR, 1) plus AOSP DeskClock's
defensive hour/minute re-assertion, keeping both engines in agreement
through any transition.
Instant-valued fields (snoozeHasta/snoozeOrigen/proximaEjecucion/
ultimaEjecucionGestionada/creadaEn/actualizadaEn) serialized as
offset-less local ISO, so re-parsing after a device timezone change
reinterpreted the same wall fields as a different instant. They now
serialize as UTC ("Z"); reads normalize to local, and legacy
offset-less payloads parse identically — no migration. fechaUnica
stays local on purpose: it is a wall-clock date.
One-shot alarms sent fechaUnica's midnight epoch to the native side,
whose boot/travel re-arm derives the calendar day back from it in the
CURRENT zone — a westward shift rolled the date to the previous day.
The channel now anchors the date at local noon, keeping it stable
across real-world zone shifts.
Property tests lock the no-drift guarantee (400 daily / 200 weekday
iterations must all land exactly at hora:minuto — on DST-observing
dev machines this crosses real transitions), plus UTC round-trip,
legacy-payload compatibility, and wall-date preservation tests.