pjfanning opened a new pull request, #1596:
URL: https://github.com/apache/poi/pull/1596

   Backport of #1592 (trunk commit 220b86e03fb928668913177ab40a384d98022980) to 
`6.0.x`. See that PR for the full list of cases and the Excel checks.
   
   ## What it changes
   
   - A last section with an unquoted `@` is the text section in a format of 
one, two or three sections (`"ID: "@`, `0.00;@`). A format with only a text 
section shows numbers as General.
   - A number in a date section is an Excel serial date in the 1900 date 
system, for every value including zero. Before, it used a 1904 epoch and failed 
for any modern serial.
   - A `Date` passed to an elapsed or number section is formatted as its serial 
number.
   - Elapsed time is rounded to seconds (or the shown fraction of a second) and 
then split, so `[h]:mm:ss` on 1.145833 is `27:30:00`, not `27:29:60`. Hours and 
minutes are truncated when nothing smaller is shown.
   - `mmmmm` is the first letter of the month. Three or more `m` are always a 
month. `m`/`mm` is the minutes only right after the hours or right before the 
seconds, so `hh:mm dd/mm/yyyy` shows the month in the date.
   - `CellFormat.apply(Object)` gives 255 `#` for a number that is not a valid 
date in a date section, as `apply(Cell)` already does.
   - `DateFormatNumberTests.xlsx` is converted from the 1904 to the 1900 date 
system, as on trunk.
   
   ## Differences from the trunk commit
   
   - `6.0.x` does not have the trunk null checks in `CellFormat.apply(Object)`, 
so the invalid-date check is applied without the "no applicable format part 
found" check that surrounds it on trunk.
   - The trunk-only `testApplyNPE*` and `testApplyClassCaseException` tests, 
which belong to those null checks, are not included.
   - `TestCellFormat` gains an `assertThrows` import that trunk already had.
   
   ## Behaviour changes to be aware of in a patch release
   
   No API changes, but existing formats can print differently:
   
   - Small numbers in date sections are 1900-based dates, not 1904-based; 0 is 
`1899-12-31`, not `1904-01-01`.
   - `"ID: "@` on 12.5 is `12.5`, not `ID: 12.5`; `yyyy-mm-dd;@` on -1 is 255 
`#`, not `1.0`.
   - `mmm` or longer after an `h` part is a month name, not minutes; `mmmmm` is 
one letter, not the full name.
   - `CellDateFormatter.formatValue` / `CellFormatPart.apply` called directly 
with a negative number throws `IllegalArgumentException`.
   
   These also reach `DataFormatter` for formats it hands to `CellFormat` (three 
or more sections, or a range condition).
   
   ## Testing
   
   Run locally: `org.apache.poi.ss.format.*`, `TestDataFormatter`, 
`TestHSSFDataFormatter` and `TestDateUtil` in poi (192 tests, all pass), and 
`org.apache.poi.ss.tests.format.*` and `TestXSSFDataFormat` in poi-ooxml 
(pass). The rest of the suite is left to CI.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to