Repository navigation
Conversation
XML Schema writes a duration with or without zero-valued years and months (P0Y0M1DT3H is P1DT3H), but the importer only read days and time, so the padded spelling became text. A zero count of years or months is now read past; a nonzero one still keeps the value as text, since years and months have no fixed length in days. Fixes storytold#4358.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Fixes #4358
What was wrong
parse_durationincrates/xlsx/src/ods.rsreads an ODSoffice:time-value, which ODF defines as an XML Schemaduration. It read days and the time part, but not years or months. A duration that spells out zero years or months (P0Y0M1DT3H, the same length asP1DT3H) became text, and stayed text in an XLSX save, with the generic "unsupported values" warning.The issue notes that Excel rejects the padded spelling too. So this is about reading the format as its standard defines it, for files from other producers, rather than about matching Excel. Only values that were text before change; every duration GridCraft already read reads the same.
What changed
0Y,0M,00Y) at the start of the date part is read past.P1Y,P0Y1M) still keeps the value as text. Years and months have no fixed length in days, which is why they were refused, and that reason still holds.Y, thenM, beforeDandT);P0M0Y1Dstays text.QA report
Main vs branch, end to end (
gridcraft-cli, an ODS file)dur.odsis a minimal ODS package I assembled. One row holds the issue's five pairs astimecells, thenP1YandP0Y1M, then the number 42 as a float control. Each build converted it withrun --in dur.ods --out out.xlsx, and I evaluated=IF(ISNUMBER(X1),ROUND(X1*24,4)&"h","text:"&X1)on each cell of the.xlsx.mainis agridcraft-clibuilt fromorigin/main(abcfc191); the branch is this PR (4ab70c0e).P1DT3H/P0Y0M1DT3HPT3H/P0MT3H-PT2H/-P0YT2HPT0S/P0Y0M0DP1DT2H3M4.5S/P0Y0M1DT2H3M4.5SP1Y,P0Y1M(non-zero years or months)Both builds still warn about unsupported values, because
P1YandP0Y1Mare still text.Test
tests::ods_tests::ods_durations_read_zero_years_and_monthscovers:P0Y0M1DT3His 1.125);P1Y,P0Y1M,P0M0Y1D(out of order),P0Y0MT(an empty time part) andP0YX, all kept as text;P00Y, read as zero.The existing ODS tests, including
P1MandPT2M1Hstaying text, still pass.Negative control
With the year and month step skipped (on top of
4ab70c0e, then restored withgit checkout), the test fails at the first pair: leftNumber(1.125), rightText("P0Y0M1DT3H").Gate (macOS arm64)
cargo fmt --all -- --checkcargo clippy -p gridcraft-xlsx --all-targets -- -D warningscargo test -p gridcraft-xlsx -p gridcraft-engineNot covered
parse_datein the same file, a different function. The two tests sit in different places.cargo xtask ci: I didn't run the fullcargo xtask ci(wasm, layers, the other crates).Summary by CodeRabbit