mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-24 10:16:59 -06:00
* Dedupe the 400-year-cycle UTC conversion and the EPUB package writer SonarCloud flagged new-code duplication on main (17%): five copies of the "move the instant into chrono's range by whole 400-year cycles" conversion and two copies of the EPUB OPF/container/zip writer. - designcraft-doc gains a `time` module: `date_parts(days)` and `utc_parts(secs, nanos)`. App logging, EPUB `iso8601`, PDF `civil`, PPTX `civil` and text-variable `civil` are now thin callers; each keeps its own format string and year clamp. The app reaches it through `designcraft_engine::doc`, so its direct chrono dependency is dropped. - EPUB: `package_opf` + `write_package` shared by fixed-layout and reflowable export (same entry order and compression). - Boundary tests on the helper: pre-1970, year 9999 -> 10000, i64 extremes, nanos past a second. Output is unchanged: existing date tests pass, and fixed/reflowable EPUBs (with/without cover, author, pre-1970 and i64::MAX dates) are byte-identical to origin/main. * time: drop the unreachable i128 clamp and match arms in utc_parts Whole 400-year cycles times 400 stay under 2.6e16 for any i64 day count, so the year can't overflow i64 and the i128 + saturate was dead code (carried over from the copies this replaced). The date and time lookups can't fail either; each keeps one unwrap_or_default instead of a match with a fake 1970 fallback. Output and tests unchanged.