Bug 163834 - Conditional formatting Date is Last week shows 8 days on Sundays instead 7
Summary: Conditional formatting Date is Last week shows 8 days on Sundays instead 7
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Conditional-Formatting
  Show dependency treegraph
 
Reported: 2024-11-10 08:37 UTC by Dragan Marinović
Modified: 2024-11-11 05:01 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Calc inbuilt conditional formatting Date is Last week not working (2.89 MB, application/zip)
2024-11-10 08:39 UTC, Dragan Marinović
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dragan Marinović 2024-11-10 08:37:52 UTC
Description:
Format > Conditional > Condition > More rules > Date is > Last week
Shows 8 conditionally formatted dates instead of 7 on Sundays.

Method:
Open Attachments
    - video (my screencast of short explanation of problem)
    - ods file

I’ve read that Date is: Last / This / Next week is locale dependent
and cause I use a lot of mixed locale I created custom formulas
for Last / This / Next week with week starting on Monday and Sunday.
If I didn’t I wouldn’t notice it.

Open file:

Columns:
    1. Week Start: Mon – Custom formula
    2. Locale dependent –  Calc inbuilt conditional formatting – Date is: Last / This / Next week
    3. Locale dependent –  Formula I got from .xls (Excel 97-2003 file) made in Excel 365
    4. Week Start: Sun – Custom formula

Try to set manual date and press delete on empty cell so it can recalculate.
If set on Sunday you will see that Calc inbuilt conditional formatting – Date is: Last week if day is Sunday doesn’t work correctly. It conditionally formats 8 days instead of 7 days.

With “View > Show formulas” you can see that dates and added / subtracted
from TODAY() in middle. That seems not to be the problem. Cause if you
paste date as values problem still persists.

To see formulas for Conditional Formatting:
    Format > Conditional > Manage

Tried:
    - many LibreOffice versions
    - many Linux distorts (even online)
    - Windows in VM
    - resetting user profile
    - resetting mixed locale
    - recreating file in MS Excel 365 and opening it in Calc.
and they all show the same mistake.

Steps to Reproduce:
-

Actual Results:
-

Expected Results:
-


Reproducible: Always


User Profile Reset: Yes

Additional Info:
-
Comment 1 Dragan Marinović 2024-11-10 08:39:45 UTC
Created attachment 197518 [details]
Calc inbuilt conditional formatting Date is Last week not working
Comment 2 Regina Henschel 2024-11-10 17:45:20 UTC
I think, it is an error in https://opengrok.libreoffice.org/xref/core/sc/source/core/data/conditio.cxx?r=621caf93#1649

condformat::NEXTWEEK is true, when rActDate+7 fulfills the conditions of THISWEEK. And condformat::LASTWEEK is true, when rActDate-7 fulfills the conditions of THISWEEK.

That is true for all cases but LASTWEEK case sunday.
It should be
begin = rActDay-7, end = rActDay-7 + 6
but it is
begin = rActDay-8, end = rActDay-1
Comment 3 BogdanB 2024-11-10 18:12:11 UTC
Eike Rathke, I added you here. Can you please take a look?