[Libreoffice-bugs] [Bug 139421] Calc: calcuate weeknumber-year missing in 2021

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Wed Jan 6 05:31:10 UTC 2021


https://bugs.documentfoundation.org/show_bug.cgi?id=139421

--- Comment #7 from Robert Lacroix <ralacroix at hydro.mb.ca> ---
(In reply to Regina Henschel from comment #3)
> The function WEEKNUM has a second parameter to determine the mode of
> calculation. It defaults to 1, which is not the ISO way. To get the ISO
> calculation you have to use parameter 21. Or you use function ISOWEEKNUM.
> Please read help for WEEKNUM and ISOWEEKNUM of a current release.
> 
> I cannot confirm the initial reported results
> =TEXT(A1;"yyyy-WW") returns correctly the ISO week number
>   2020-53 for date 2020-12-31.
>   2021-53 for dates 2021-01-01, 2021-01-02, 2021-01-03
>   2021-1  for dates 2021-01-04 (Monday) to 2021-01-10 (Sunday)
Is that a typo TEXT value with the middle row of dates? The year-weeknum is
non-monotonic for increasing dates. 2021-53 should come after 2021-1 in a
sequence of successive dates.

The OP is asking for a WEEKNUM mode from "system 1", which is any mode except
the ISO mode. System 1 always puts January 1 in week 1, and the preceding
December days in the same week are also in week 1 (of the following calendar
year). The day you select as the start of the week determines the particular
WEEKNUM mode. For symmetry with ISO mode, I would start the week on Monday, so
use WEEKNUM mode 2 (or 11).

The question arose on how to select a mode/format with the TEXT function.
There are 4 options:
1) add a new format code to TEXT was suggested. It's legacy compatible.
2) add a document option. It would be buried in options, so not nice to use.
3) add an optional argument to TEXT, a-la WEEKNUM; default ISO mode for legacy
compatibility?
4) make meaning of current format depend on locale. Undesireable, causes global
side effects if I need to change locale for one spreadsheet cell.

I would select option 3. It's compatible, more flexible, and the value
displayed with TEXT in one cell can be easily made to match any integer result
of WEEKNUM in another cell.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20210106/ce686815/attachment.htm>


More information about the Libreoffice-bugs mailing list