feat(odf): write a date and a time into an ods cell - #977
Merged
Merged
Conversation
andiwand
force-pushed
the
feat/date-serials
branch
from
October 4, 2026 10:57
6de1ffd to
e4efde6
Compare
andiwand
force-pushed
the
feat/ods-write-dates
branch
from
October 4, 2026 10:57
dcca778 to
ee25c2b
Compare
andiwand
force-pushed
the
feat/date-serials
branch
from
October 4, 2026 11:03
e4efde6 to
b30fdc0
Compare
`sheet_set_cell` takes a date or time `CellValue` that states its number. A date writes `office:value-type="date"` and an `office:date-value`, with its time where it has one; a time writes `office:time-value` as a duration. The `text:p` comes from the cell's date or time data style where it has one, and from the typed text otherwise. A time of day does not move onto the 1900 system, so it stays positive. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011qFgpigFCwbfZ24TFj7eqA
An `office:date-value` spells its year in four digits, so a date outside the years 1 to 9999 gave a value that the reader refuses. A very large number also overflowed the calendar arithmetic. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011qFgpigFCwbfZ24TFj7eqA
andiwand
force-pushed
the
feat/ods-write-dates
branch
from
October 4, 2026 11:13
ee25c2b to
3c8286b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Generated with Claude Code
Step 2 of the typed-dates plan (decision 18, the ods half).
Change
writabletakes a date or time value that states its number. One without a number is still refused, before the cell changes.office:value-type="date"andoffice:date-value, eitherYYYY-MM-DDorYYYY-MM-DDTHH:MM:SSwhen it has a time of day.number_format::civil_from_daysturns the days back into a civil date.office:value-type="time"andoffice:time-valueas a duration,PT18H30M00S, with hours past 24 where the value runs over a day.shown_numberbecomesshown_value. A date or time takes itstext:pfrom the cell's date or time data style, and a number from its number style. A cell whose data style is of the other kind, or which has none, keeps the typed text.serial_from_dayswould make a time of day negative, and the formatter then falls back toGeneral. The LibreOffice probe below found that:18:30showed as-0.229166666666667before the fix.Review after the rebase
A date outside the years 1 to 9999 wrote an
office:date-valuethat the reader refuses, and a very large number overflowed the calendar arithmetic.writablenow refuses such a date, and a time that is not finite;a_date_past_9999_or_an_infinite_time_refusescovers both.civil_from_daysreturnsstd::uint32_tand has a qualified definition, as #976 now does. The rest holds: the floor of a negative day, the duration spelling, and the choice of a style by the category of the value.Proof
OdfSheetWritetests:dateop into add.mm.yyyycell gives02.01.2025;hh:mmcell gives18:30;OdfSheetWrite.*,OdfSheetValue.*,NumberFormat.*,Ooxml*,html.*,Csv*and the edit suites: 357 passed.dd.mm.yyyy,hh:mmandyyyy-mm-dd hh:mmcells to ods.back_translatewrote a date, a time, a date with a time, and a date into a plain cell. LibreOffice's csv export reads each value as written:02.01.2025,18:30,2025-01-02 18:00,01/02/25 12:00 AM. Ourtext:pagrees for every styled cell. The plain cell keeps the typed1/2/2025, while LibreOffice renders it in its own default date format.g++-15 -Wall -Wextra -Werroris clean on the touched files.