| Summary: | Duration formats ([HH]:MM:SS, [MM]:SS, [SS]) are limited to max uint32 seconds values. | ||
|---|---|---|---|
| Product: | LibreOffice | Reporter: | L.H. Carsten <info> |
| Component: | Calc | Assignee: | Not Assigned <libreoffice-bugs> |
| Status: | RESOLVED NOTABUG | ||
| Severity: | normal | CC: | erack, himajin100000, miguelangelrv |
| Priority: | medium | ||
| Version: | 6.4.7.2 release | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: | https://bugs.documentfoundation.org/show_bug.cgi?id=144697 | ||
| Whiteboard: | |||
| Crash report or crash signature: | Regression By: | ||
|
Description
L.H. Carsten
2022-03-07 11:48:23 UTC
I cannot reproduce with current 7.3.1.3, even not taking into account that HH:MM:[SS] and HH:[MM]:SS are both invalid format strings (the square brackets must be applied to the most significant category, so either [MM]:SS, or [SS], but no time pieces to the left of the square brackets). Anyway, I put 150 to A1 (which means "150 days"), and format it to the invalid 'HH:MM:[SS]', and I get the cell display 00:00:12960000, where 12960000 is the correct number of seconds in 150 days. (In reply to L.H. Carsten from comment #0) > 1.Enter a number larger than 86399 in a cell Ah - I'm sorry, the number larger than 86399. In last versions, it is fixed - in a way that for any number larger than 49710, [SS] and [MM]:SS shows #FMT (see bug 129878). Further experimentation shows that if one adds cells already formatted as time, the result WILL exceed the maximum earlier mentioned. Obviously the format of the cell with the sum value needs to use the brackets. Sorry Mike, I didn't notice your comment when I added mine (#3). Ok so it's already fixed and I need to update. I will have to wait though till the update is in my package system. That's not a problem. My goal was to make this info available and didn't find a report on this issue. So thanks for your quick response. > that HH:MM:[SS] and HH:[MM]:SS are both invalid format strings (the square brackets must be applied to the most significant category, so either [MM]:SS, or [SS], but no time pieces to the left of the square brackets).
Indeed, that makes sense. It delivers the same result nevertheless, so I didn't notice that mistake! :)
In SvNumberformat::ImpGetTimeOutput(), hour, minute and second values are calculated using uint32 and fTime (seconds in double) is limited to D_MAX_U_INT32. Maybe instead we could use uint64 and limit fTime more sensibly depending on how many decimal fractions are to be displayed (e.g. 2^52-1 largest integer value representable in double if no fractions, 2^48-1 if one decimal, 2^44-1 if two, ...), i.e. 2^(52-nCntPost*4)-1 or some such. The duration formats display #FMT since LO 7.0.0 for >4294967296 seconds (71582788 minutes, 1193046 hours, 49710 days). Fwiw, the input value 86399 is in *days* (not seconds), that would be 86399*86400=7464873600 seconds or 124414560 minutes or 2073576 hours. (In reply to L.H. Carsten from comment #0) > ... > 2.Enter =TIME(0,0,A1) in 3 other cells (e.g. B1,B2,B3) > ... I'm wrong or TIME() gives a time result as part of one day 23:59:59 =TIME(0;0;86399) 23:59:00 =TIME(0;86399;0) 23:00:00 =TIME(86399;0;0) it returns the maximum for seconds, minutes or hours, and the format [xx] has only one value to sum. I think there is not a bug. (In reply to m.a.riosv from comment #7) > (In reply to L.H. Carsten from comment #0) > > ... > > 2.Enter =TIME(0,0,A1) in 3 other cells (e.g. B1,B2,B3) > > ... > > I'm wrong or TIME() gives a time result as part of one day > 23:59:59 =TIME(0;0;86399) > 23:59:00 =TIME(0;86399;0) > 23:00:00 =TIME(86399;0;0) > it returns the maximum for seconds, minutes or hours, and the format [xx] > has only one value to sum. > > I think there is not a bug. Indeed it seems the 'issue' is with the Time function not with the cell format. Change the cell format to number general and the output of the =Time() is always < 1 Not sure if it's a bug or a feature though! Same as Excel, TIME() returns a value in the interval (0,1] (or rather the decimal representation of 00:00:00 to 23:59:59 in fractions of a day) applying a modulo operation on its arguments. Sorry, interval [0,1) of course.. I suggest this bug report can be closed as resolved, no bug! Sorry for my confusion. |