Bug 139548 - =WEEKNUM(xxx;2) Returns Wrong Week Number for 2021
Summary: =WEEKNUM(xxx;2) Returns Wrong Week Number for 2021
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.0.4.2 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-11 19:15 UTC by Gunter Ohrner
Modified: 2021-01-12 10:18 UTC (History)
0 users

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gunter Ohrner 2021-01-11 19:15:31 UTC
Description:
If I don't significantly misread all documentation I could find, WEEKNUM does not work as documented for the year 2021:

https://help.libreoffice.org/7.0/en-US/text/scalc/01/func_weeknum.html?&DbPAR=WRITER&System=UNIX

System 2

> The week containing the first Thursday of the year is the first week of the
> year, and is numbered week 1. That means that week number 1 of any year is
> the week that contains January 4th. ISO 8601 defines this system and that the
> week starts on Monday.

However:

01.01.21	1	=KALENDERWOCHE(A1;2)
02.01.21	1	=KALENDERWOCHE(A2;2)
03.01.21	1	=KALENDERWOCHE(A3;2)
04.01.21	2	=KALENDERWOCHE(A4;2)
05.01.21	2	=KALENDERWOCHE(A5;2)
06.01.21	2	=KALENDERWOCHE(A6;2)
07.01.21	2	=KALENDERWOCHE(A7;2)


Steps to Reproduce:
1. Use the example data pasted to the description field


Actual Results:
The week containing the 4th of January is counted as "week 2".

Expected Results:
The week containing the 4th of January should be counted as "week 1". That's what the documentation states, and also what my calendar says...


Reproducible: Always


User Profile Reset: No



Additional Info:
Reproducable in both
* 7.0.4.2 Linux 64 Bit desktop binary
* and LibreOffice 6.4 (Collabora CODE).
Comment 1 [REDACTED] 2021-01-11 23:03:21 UTC
Documentation https://help.libreoffice.org/7.0/en-US/text/scalc/01/func_weeknum.html?&DbPAR=WRITER&System=UNIX states:

System 2
	
> The week containing the first Thursday of the year is the first week of the year, > and is numbered week 1. That means that week number 1 of any year is the week
> that contains January 4th. ISO 8601 defines this system and that the week starts on Monday.

And the table below shows the following modes for System 2

> System 2    21   Monday (ISO 8601)
>             150  (ISO 8601, for interoperability with Gnumeric)

Hence you need Mode=21 (not Mode 2, which is a mode of System 1) and you'll get:

Date DD.MM.YYYY)	Weeknum	Formula
01.01.2021	53	=WEEKNUM(A2;21)
02.01.2021	53	=WEEKNUM(A3;21)
03.01.2021	53	=WEEKNUM(A4;21)
04.01.2021	1	=WEEKNUM(A5;21)
05.01.2021	1	=WEEKNUM(A6;21)
06.01.2021	1	=WEEKNUM(A7;21)
07.01.2021	1	=WEEKNUM(A8;21)

From my point of view: Not a bug
Comment 2 Gunter Ohrner 2021-01-12 10:18:50 UTC
Whoops, ok, PEBKAC, sorry. :-(

http://ars.userfriendly.org/cartoons/?id=19980506