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

   Four places where `CellFormat` disagrees with Excel, one commit each.
   
   ## Summary
   
   ```diff
    CellFormat(format)                       // one section
   -  textFmt = default "@"
   +  textFmt = the section, if it is a text section     // "ID: "@ , @@ , @" 
text"
   
    CellFormat.apply(Date)
      part = getApplicableFormatPart(serial)
   -  part.apply(date)
   +  part is DATE ? part.apply(date) : part.apply(serial)   // [h]:mm:ss, 0.00 
on a Date
   
    CellDateFormatter.formatValue(Number)
   -  1904 epoch + MathUtil.safeDoubleToInt(seconds)    // overflows for any 
modern serial
   +  DateUtil.getJavaDate(serial, 1900 windowing, user time zone, round 
seconds)
   
    CellElapsedFormatter.formatValue
   -  each part rounded on its own                     // 27:29:60, [ss].00 -> 
451810.100
   +  round the value to the smallest unit shown, then split with integer 
arithmetic
   
    CellDateFormatter "mmmmm"
   -  full month name
   +  first letter of the month (as DataFormatter does)
   ```
   
   The `CellFormat.apply(Date)` change also fixes DataFormatter for 
multi-section formats with an elapsed section, such as `[h]:mm:ss;"<0";"0";@" 
h"`. DataFormatter hands those to `CellFormat` with a Date, which made the 
elapsed section throw, so DataFormatter fell back to formatting the whole 
format string.
   
   ## Evidence
   
   The new tests in `TestCellFormat` fail on trunk and pass with this branch:
   
   | Test | Trunk | This branch |
   | --- | --- | --- |
   | `testSingleTextSectionFormatsText`: `"ID: "@` on `Mixer-01` | `Mixer-01` | 
`ID: Mixer-01` |
   | `testNumberInDateSection`: `yyyy-mm-dd hh:mm:ss` on 45873.9314 | 
`IllegalArgumentException: Value out of range: 3.963507675E9` | `2025-08-04 
22:21:15` |
   | `testDateInElapsedAndNumberSections`: `[h]:mm:ss` on a Date | 
`IllegalArgumentException: Expected object of type number` | `25:00:00` |
   | `testElapsedTimeRoundsAsAWhole`: `[h]:mm:ss` on 1.145833 | `27:29:60` | 
`27:30:00` |
   | `testMultiSectionElapsedFormat`: also through `DataFormatter` | `27:29:60` 
| `27:30:00` |
   | `testMonthInitial`: `mmmmm` | fails (number in a date section) | `A` |
   
   `TestCellFormat`, `TestCellFormatCondition`, `TestCellFormatResult`, 
`TestSimpleFraction`, `TestDataFormatter` and `TestHSSFDataFormatter` all pass.
   
   ## Merge Danger
   
   **Door:** two-way. No API or signature changes; each commit reverts on its 
own.
   
   **Blast Radius:** formatting output. Callers that relied on the old results 
get Excel's text instead:
   - text values with a one-section `@` format;
   - numbers passed to date formats, which threw before;
   - elapsed times that showed `:60`;
   - `mmmmm`.
   
   🤖 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