ODFF1.2 interpretation of function WEEKNUM
antlists at youngman.org.uk
Fri Sep 22 19:36:57 UTC 2017
On 18/09/17 16:20, Winfried Donkers wrote:
> Hi Eike,
> I'm working on tdf112320 and I think that ODFF1.2 may be ambiguous with
> respect to WEEKNUM
> My interpretation of the Semantics for Mode 1,2,11-17 was that
> 'every week starts on Sunday..Saturday, depending on the value of Mode.
> The week containing 1 January is week 1'.
Is this supposed to be analogous to the ISO week? Because that's
different again ...
ISO weeks start on Monday, finish on Sunday.
> So, WEEKNUM(DATE(2014,12,29),1) returns 1, as it is a Monday, the week
> starts on Sunday 28 December and 1 January is on the Thursday. All weeks
> have 7 days.
> However, both Excel and Gnumeric use
> 'every week starts on Sunday..Saturday, depending on the value of Mode,
> _or_ on 1 January (with the week number 1)'.
> So, WEEKNUM(DATE(2014,12,29),1) returns 53, as it is a Monday, following
> week 52 and WEEKNUM(DATE(2015,1,1),1) returns 1. Week 53 has 4 days and
> week 1 has 3 days.
> When I read ODFF1.2 again (and again) I read the first interpretation
> (WEEKNUM(DATE(2014,12,29),1)=1). But is that correct??
> As it is now, Calc produces different results when compared to Excel and
> What is your interpretation?
ISO states that the week is Monday to Sunday, and it belongs to the year
in which the majority of it falls. (At least, I'm pretty certain it
does, I'd be rather shocked if somebody shows me otherwise.)
In practice, that means every Thursday will fall in its own year, so the
week number is equal to the count of Thursdays so far. If 31 Dec is a
Thursday, then 1,2,3 Jan will be week 53 of the previous year. If 1 Jan
is a Thursday, then 29,30,31 Dec will be week 1 of the following year.
There's some nifty code on a site called Pickwiki that calculates the
ISO weeknum based on this Thursday fact that I could point you to
(disclaimer, I wrote it), but the important point is that none of the
functions you have referenced appear to return the ISO weeknum.
More information about the LibreOffice