Bug 156766

Summary: Complex formula with WEEKNUM result restarts after 31st week of year
Product: LibreOffice Reporter: Gabor Kelemen (allotropia) <kelemeng>
Component: CalcAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: normal CC: serval2412
Priority: medium    
Version: 3.6.0.4 release   
Hardware: All   
OS: All   
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 108253    
Attachments: Example file from LO master
How the example file looks in master
How the example file looks in Excel 2016 and master
quick fixed Formulas in the Weeknumber-Columns
shows the bad formatting on output from WEEKNUM(…)

Description Gabor Kelemen (allotropia) 2023-08-14 11:12:57 UTC
Created attachment 188964 [details]
Example file from LO master

Attached user made (saved as ods from an Excel file by LO) file contains some complex formula, mainly building on the WEEKNUM function.
The expectation is that in every fifth column the number of the week is calculated next to the Monday cell of a week.
This works fine until the formula result is not greater than 31, but after that it restarts at 1 instead of continuing with 32... until 52.

1. Open attached file
2. Notice the calculated week numbers in column AC of the first sheet
-> In AC17 the result is 1 instead of 32

Version: 24.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 218a7650a5cf03f895bed19c68d6f02daec536e9
CPU threads: 15; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: threaded

and back until 3.6. In 3.5 however the numbering did not restart, although it did not give the same results as today either - calculated results were larger by 1.
Which interestingly is pretty similar how Excel 2016 calculates using the same ods file.

Bibisect with linux-4.3all got this range, but nothing sticks out to me:

https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=73202f8edc074ec035255d25ff29bfd4a8d8dfd6..6b11a18071254a443c8fe7e7b0b1c95b0f9fd35e
Comment 1 Gabor Kelemen (allotropia) 2023-08-14 11:16:35 UTC
Created attachment 188965 [details]
How the example file looks in master
Comment 2 Gabor Kelemen (allotropia) 2023-08-14 11:17:15 UTC
Created attachment 188966 [details]
How the example file looks in Excel 2016 and master
Comment 3 Julien Nabet 2023-08-14 11:48:56 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.
Comment 4 Werner Tietz 2023-08-14 12:10:22 UTC
this is Error by User with stupid **TT.** Format in the Style of Conditional Format.
This stupid Document needs a complete rework!

NOTABUG
Comment 5 Werner Tietz 2023-08-14 12:24:29 UTC
Created attachment 188969 [details]
quick fixed Formulas in the Weeknumber-Columns
Comment 6 Werner Tietz 2023-08-14 13:56:29 UTC
Created attachment 188971 [details]
shows the bad formatting on output from WEEKNUM(…)