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

   Builds on #1591 by devaskim (its four commits are kept as they are) and adds 
one commit that fixes the problems found when reviewing it. Supersedes #1591.
   
   ## From #1591
   
   - A one-section format with a text placeholder (`"ID: "@`, `@@`) formats 
text values.
   - A number in a date section is an Excel serial date (1900 date system). On 
trunk it used a 1904 epoch and overflowed for any modern serial.
   - A `Date` passed to an elapsed or number section is formatted as its serial 
number.
   - Elapsed time is rounded once and then split, so `[h]:mm:ss` on 1.145833 is 
`27:30:00`, not `27:29:60`.
   - `mmmmm` is the first letter of the month.
   
   ## Added here
   
   | Case | #1591 | This PR |
   | --- | --- | --- |
   | `[h]:mm` on 1:30:45 | `1:31` | `1:30` (as trunk and `DataFormatter`) |
   | `[h]` on 1.6 hours | `2` | `1` |
   | `yyyy-mm-dd hh:mm` on 0 | `1904-01-01 00:00` | `1899-12-31 00:00` (same 
epoch as 0.25) |
   | `yyyy-mm-dd` on -1 via `CellFormat.apply(Object)` | 
`IllegalArgumentException` | 255 `#`, as `apply(Cell)` already gives |
   | cached format reused after the user time zone changes | hours shifted | 
unchanged |
   | `mmmm mmmmm` | `A A` | `August A` |
   | `hh:mmmmm` | `22:00021` | `22:A` |
   
   - **Elapsed formats:** the value is rounded to seconds, or to the fraction 
of a second shown. Hours and minutes are truncated when nothing smaller is 
shown.
   - **Zero:** the leftover 1904 special case for 0 is removed.
   - **Time zone:** the serial date is converted in the time zone of the 
formatter's `SimpleDateFormat`, not the user time zone at call time.
   - **`mmmmm`:** tracked per month part instead of per format. Three or more 
`m` are always a month, never minutes.
   - **`DateFormatNumberTests.xlsx`:** this was a 1904-date-system workbook, 
which is why `TestCellFormatPart.testDateFormatNumbers` failed on #1591. It now 
uses the 1900 date system and the cached expected text is `1900-01-01 …` 
instead of `1904-01-02 …`.
   
   ## Behaviour changes to be aware of
   
   - Numbers in date sections: small serials that trunk showed as 1904-based 
dates are now 1900-based.
   - `CellDateFormatter.formatValue` / `CellFormatPart.apply` called directly 
with a negative number throws `IllegalArgumentException`; trunk produced a 
pre-1904 date.
   - `mmm` or longer after an `h` part is a month name; trunk printed minutes.
   
   ## Testing
   
   Run locally on Java 17: `org.apache.poi.ss.format.*`, `TestDataFormatter`, 
`TestHSSFDataFormatter`, `TestDateUtil` in poi, and 
`org.apache.poi.ss.tests.format.*` and `TestXSSFDataFormat` in poi-ooxml. All 
pass. The rest of the suite is left to CI.
   
   The hour/minute truncation matches trunk and `DataFormatter`; it was not 
checked against Excel itself.
   
   🤖 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