diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2021-11-16 16:55:52 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2021-11-29 09:07:51 +0100 |
commit | 105196aa00bc0d3e426796f6729a8e7e51271e56 (patch) | |
tree | 588e0808ac1bd3e9105f3567279c21d495214068 | |
parent | 5db7694a6377d32bdef293b4ece27b471c3ea427 (diff) |
tdf#145578, tdf#145587 revise calculations for WEEKS Add-In function
The calculations now follow the documentation for WEEKS in
https://wiki.documentfoundation.org/Documentation/Calc_Functions/WEEKS.
Change-Id: Ifede6e2ec2d9cfb7301fd5eb53bf7b6f187053bc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125319
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sc/qa/unit/data/functions/date_time/fods/weeks.fods | 652 | ||||
-rw-r--r-- | scaddins/source/datefunc/datefunc.cxx | 71 |
2 files changed, 659 insertions, 64 deletions
diff --git a/sc/qa/unit/data/functions/date_time/fods/weeks.fods b/sc/qa/unit/data/functions/date_time/fods/weeks.fods index a0d596086220..f05803ea6684 100644 --- a/sc/qa/unit/data/functions/date_time/fods/weeks.fods +++ b/sc/qa/unit/data/functions/date_time/fods/weeks.fods @@ -1056,25 +1056,657 @@ <table:table-cell table:number-columns-repeated="3"/> </table:table-row> <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:number-columns-repeated="7"/> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2022;1;2);DATE(2022;1;9);1)" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce31" table:formula="of:=[.A12]=[.B12]" office:value-type="boolean" office:boolean-value="false" calcext:value-type="boolean"> + <text:p>ONWAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A12])" office:value-type="string" office:string-value="=WEEKS(DATE(2022;1;2);DATE(2022;1;9);1)" calcext:value-type="string"> + <text:p>=WEEKS(DATE(2022;1;2);DATE(2022;1;9);1)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145578</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="5"/> <table:table-cell office:value-type="float" office:value="17" calcext:value-type="float"> <text:p>17</text:p> </table:table-cell> <table:table-cell table:number-columns-repeated="3"/> </table:table-row> <table:table-row table:style-name="ro2"> - <table:table-cell table:number-columns-repeated="2"/> - <table:table-cell table:style-name="ce19"/> - <table:table-cell table:style-name="ce26"/> - <table:table-cell table:number-columns-repeated="5"/> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2022;1;3);DATE(2022;1;10);1)" office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce31" table:formula="of:=[.A13]=[.B13]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>WAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A13])" office:value-type="string" office:string-value="=WEEKS(DATE(2022;1;3);DATE(2022;1;10);1)" calcext:value-type="string"> + <text:p>=WEEKS(DATE(2022;1;3);DATE(2022;1;10);1)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145578</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> <table:table-cell table:style-name="ce27"/> <table:table-cell table:style-name="ce29" office:value-type="date" office:date-value="2001-12-01" calcext:value-type="date"> - <text:p>12/01/2001</text:p> + <text:p>01-12-2001</text:p> </table:table-cell> <table:table-cell table:style-name="ce27" table:number-columns-repeated="3"/> </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2022;1;9);DATE(2022;1;2);1)" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="-1" calcext:value-type="float"> + <text:p>-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce31" table:formula="of:=[.A14]=[.B14]" office:value-type="boolean" office:boolean-value="false" calcext:value-type="boolean"> + <text:p>ONWAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A14])" office:value-type="string" office:string-value="=WEEKS(DATE(2022;1;9);DATE(2022;1;2);1)" calcext:value-type="string"> + <text:p>=WEEKS(DATE(2022;1;9);DATE(2022;1;2);1)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145578</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="9"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2021;11;14);DATE(2021;11;15);1)" office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce31" table:formula="of:=[.A15]=[.B15]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>WAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A15])" office:value-type="string" office:string-value="=WEEKS(DATE(2021;11;14);DATE(2021;11;15);1)" calcext:value-type="string"> + <text:p>=WEEKS(DATE(2021;11;14);DATE(2021;11;15);1)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="9"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2021;11;14);DATE(2021;11;15);0)" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce31" table:formula="of:=[.A16]=[.B16]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>WAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A16])" office:value-type="string" office:string-value="=WEEKS(DATE(2021;11;14);DATE(2021;11;15);0)" calcext:value-type="string"> + <text:p>=WEEKS(DATE(2021;11;14);DATE(2021;11;15);0)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce28"/> + <table:table-cell table:style-name="ce27" table:number-columns-repeated="4"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2010;01;01);DATE(2011;01;01);1)" office:value-type="float" office:value="52" calcext:value-type="float"> + <text:p>52</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="52" calcext:value-type="float"> + <text:p>52</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce31" table:formula="of:=[.A17]=[.B17]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>WAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A17])" office:value-type="string" office:string-value="=WEEKS(DATE(2010;01;01);DATE(2011;01;01);1)" calcext:value-type="string"> + <text:p>=WEEKS(DATE(2010;01;01);DATE(2011;01;01);1)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145578</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="9"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS(DATE(2011;01;01);DATE(2010;01;01);1)" office:value-type="float" office:value="-52" calcext:value-type="float"> + <text:p>-52</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="-52" calcext:value-type="float"> + <text:p>-52</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce31" table:formula="of:=[.A18]=[.B18]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>WAAR</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A18])" office:value-type="string" office:string-value="=WEEKS(DATE(2011;01;01);DATE(2010;01;01);1)" calcext:value-type="string"> + <text:p>=WEEKS(DATE(2011;01;01);DATE(2010;01;01);1)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145578</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="9"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.$K$19];[.$K$20];0)" office:value-type="float" office:value="3" calcext:value-type="float"> + <text:p>3</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="3" calcext:value-type="float"> + <text:p>3</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A19]=[.B19]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A19])" office:value-type="string" office:string-value="=WEEKS($K$19,$K$20,0)" calcext:value-type="string"> + <text:p>=WEEKS($K$19,$K$20,0)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145578</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="5"/> + <table:table-cell table:style-name="ce31" office:value-type="date" office:date-value="-0001-11-25" calcext:value-type="date"> + <text:p>Sat -0001-11-27</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="3"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.$K$19];[.$K$20];1)" office:value-type="float" office:value="4" calcext:value-type="float"> + <text:p>4</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="4" calcext:value-type="float"> + <text:p>4</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A20]=[.B20]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A20])" office:value-type="string" office:string-value="=WEEKS($K$19,$K$20,1)" calcext:value-type="string"> + <text:p>=WEEKS($K$19,$K$20,1)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145578</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce27"/> + <table:table-cell table:style-name="ce31" office:value-type="date" office:date-value="-0001-12-19" calcext:value-type="date"> + <text:p>Tue -0001-12-21</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce27" table:number-columns-repeated="3"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J21];[.K21];[.M21])" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A21]=[.B21]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A21])" office:value-type="string" office:string-value="=WEEKS(J21,K21,M21)" calcext:value-type="string"> + <text:p>=WEEKS(J21,K21,M21)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="0001-01-01" calcext:value-type="date"> + <text:p>01/03/1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-29" calcext:value-type="date"> + <text:p>12/31/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J22];[.K22];[.M22])" office:value-type="float" office:value="-1" calcext:value-type="float"> + <text:p>-1</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="-1" calcext:value-type="float"> + <text:p>-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A22]=[.B22]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A22])" office:value-type="string" office:string-value="=WEEKS(J22,K22,M22)" calcext:value-type="string"> + <text:p>=WEEKS(J22,K22,M22)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="0001-01-01" calcext:value-type="date"> + <text:p>01/03/1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-29" calcext:value-type="date"> + <text:p>12/31/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J23];[.K23];[.M23])" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A23]=[.B23]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A23])" office:value-type="string" office:string-value="=WEEKS(J23,K23,M23)" calcext:value-type="string"> + <text:p>=WEEKS(J23,K23,M23)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-29" calcext:value-type="date"> + <text:p>12/31/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="0001-01-01" calcext:value-type="date"> + <text:p>01/03/1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J24];[.K24];[.M24])" office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A24]=[.B24]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A24])" office:value-type="string" office:string-value="=WEEKS(J24,K24,M24)" calcext:value-type="string"> + <text:p>=WEEKS(J24,K24,M24)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-29" calcext:value-type="date"> + <text:p>12/31/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="0001-01-01" calcext:value-type="date"> + <text:p>01/03/1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J25];[.K25];[.M25])" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A25]=[.B25]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A25])" office:value-type="string" office:string-value="=WEEKS(J25,K25,M25)" calcext:value-type="string"> + <text:p>=WEEKS(J25,K25,M25)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="0001-01-05" calcext:value-type="date"> + <text:p>01/07/1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="0001-01-08" calcext:value-type="date"> + <text:p>01/10/1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce27"/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J26];[.K26];[.M26])" office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A26]=[.B26]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A26])" office:value-type="string" office:string-value="=WEEKS(J26,K26,M26)" calcext:value-type="string"> + <text:p>=WEEKS(J26,K26,M26)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="0001-01-05" calcext:value-type="date"> + <text:p>01/07/1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="0001-01-08" calcext:value-type="date"> + <text:p>01/10/1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J27];[.K27];[.M27])" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A27]=[.B27]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A27])" office:value-type="string" office:string-value="=WEEKS(J27,K27,M27)" calcext:value-type="string"> + <text:p>=WEEKS(J27,K27,M27)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-22" calcext:value-type="date"> + <text:p>12/24/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-25" calcext:value-type="date"> + <text:p>12/27/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J28];[.K28];[.M28])" office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A28]=[.B28]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A28])" office:value-type="string" office:string-value="=WEEKS(J28,K28,M28)" calcext:value-type="string"> + <text:p>=WEEKS(J28,K28,M28)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-22" calcext:value-type="date"> + <text:p>12/24/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-25" calcext:value-type="date"> + <text:p>12/27/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J29];[.K29];[.M29])" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A29]=[.B29]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A29])" office:value-type="string" office:string-value="=WEEKS(J29,K29,M29)" calcext:value-type="string"> + <text:p>=WEEKS(J29,K29,M29)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-15" calcext:value-type="date"> + <text:p>12/17/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-18" calcext:value-type="date"> + <text:p>12/20/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J30];[.K30];[.M30])" office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A30]=[.B30]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A30])" office:value-type="string" office:string-value="=WEEKS(J30,K30,M30)" calcext:value-type="string"> + <text:p>=WEEKS(J30,K30,M30)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-15" calcext:value-type="date"> + <text:p>12/17/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-18" calcext:value-type="date"> + <text:p>12/20/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J31];[.K31];[.M31])" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A31]=[.B31]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A31])" office:value-type="string" office:string-value="=WEEKS(J31,K31,M31)" calcext:value-type="string"> + <text:p>=WEEKS(J31,K31,M31)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-31" calcext:value-type="date"> + <text:p>01/02/1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-29" calcext:value-type="date"> + <text:p>12/31/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J32];[.K32];[.M32])" office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A32]=[.B32]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A32])" office:value-type="string" office:string-value="=WEEKS(J32,K32,M32)" calcext:value-type="string"> + <text:p>=WEEKS(J32,K32,M32)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-31" calcext:value-type="date"> + <text:p>01/02/1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-29" calcext:value-type="date"> + <text:p>12/31/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J33];[.K33];[.M33])" office:value-type="float" office:value="2" calcext:value-type="float"> + <text:p>2</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="2" calcext:value-type="float"> + <text:p>2</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A33]=[.B33]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A33])" office:value-type="string" office:string-value="=WEEKS(J33,K33,M33)" calcext:value-type="string"> + <text:p>=WEEKS(J33,K33,M33)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-03" calcext:value-type="date"> + <text:p>12/05/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-22" calcext:value-type="date"> + <text:p>12/24/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J34];[.K34];[.M34])" office:value-type="float" office:value="3" calcext:value-type="float"> + <text:p>3</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="3" calcext:value-type="float"> + <text:p>3</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A34]=[.B34]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A34])" office:value-type="string" office:string-value="=WEEKS(J34,K34,M34)" calcext:value-type="string"> + <text:p>=WEEKS(J34,K34,M34)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-03" calcext:value-type="date"> + <text:p>12/05/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-22" calcext:value-type="date"> + <text:p>12/24/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J35];[.K35];[.M35])" office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A35]=[.B35]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A35])" office:value-type="string" office:string-value="=WEEKS(J35,K35,M35)" calcext:value-type="string"> + <text:p>=WEEKS(J35,K35,M35)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-03" calcext:value-type="date"> + <text:p>12/05/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-15" calcext:value-type="date"> + <text:p>12/17/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="0" calcext:value-type="float"> + <text:p>0</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2"> + <table:table-cell table:formula="of:=ORG.OPENOFFICE.WEEKS([.J36];[.K36];[.M36])" office:value-type="float" office:value="2" calcext:value-type="float"> + <text:p>2</text:p> + </table:table-cell> + <table:table-cell office:value-type="float" office:value="2" calcext:value-type="float"> + <text:p>2</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce18" table:formula="of:=[.A36]=[.B36]" office:value-type="boolean" office:boolean-value="true" calcext:value-type="boolean"> + <text:p>TRUE</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce26" table:formula="of:=FORMULA([.A36])" office:value-type="string" office:string-value="=WEEKS(J36,K36,M36)" calcext:value-type="string"> + <text:p>=WEEKS(J36,K36,M36)</text:p> + </table:table-cell> + <table:table-cell office:value-type="string" calcext:value-type="string"> + <text:p>tdf#145587</text:p> + </table:table-cell> + <table:table-cell table:number-columns-repeated="4"/> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-03" calcext:value-type="date"> + <text:p>12/05/-1</text:p> + </table:table-cell> + <table:table-cell table:style-name="ce38" office:value-type="date" office:date-value="-0001-12-15" calcext:value-type="date"> + <text:p>12/17/-1</text:p> + </table:table-cell> + <table:table-cell/> + <table:table-cell office:value-type="float" office:value="1" calcext:value-type="float"> + <text:p>1</text:p> + </table:table-cell> + <table:table-cell/> + </table:table-row> + <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> + <table:table-cell table:style-name="ce31" table:number-columns-repeated="2"/> + <table:table-cell table:style-name="Default"/> + <table:table-cell table:style-name="ce37"/> + <table:table-cell table:number-columns-repeated="10"/> + </table:table-row> <table:table-row table:style-name="ro2" table:number-rows-repeated="2"> <table:table-cell table:number-columns-repeated="2"/> <table:table-cell table:style-name="ce20"/> @@ -1150,7 +1782,7 @@ <table:table-cell table:number-columns-repeated="14"/> </table:table-row> <calcext:conditional-formats> - <calcext:conditional-format calcext:target-range-address="Sheet2.C29:Sheet2.C100 Sheet2.C20:Sheet2.C27 Sheet2.C2:Sheet2.C3 Sheet2.C14:Sheet2.C15 Sheet2.C18:Sheet2.C18"> + <calcext:conditional-format calcext:target-range-address="Sheet2.C2:Sheet2.C100"> <calcext:condition calcext:apply-style-name="Default" calcext:value="=""" calcext:base-cell-address="Sheet2.C2"/> <calcext:condition calcext:apply-style-name="Untitled1" calcext:value="=0" calcext:base-cell-address="Sheet2.C2"/> <calcext:condition calcext:apply-style-name="Untitled2" calcext:value="=1" calcext:base-cell-address="Sheet2.C2"/> @@ -1203,4 +1835,4 @@ </table:named-expressions> </office:spreadsheet> </office:body> -</office:document>
\ No newline at end of file +</office:document> diff --git a/scaddins/source/datefunc/datefunc.cxx b/scaddins/source/datefunc/datefunc.cxx index dc015e5ef0bd..fc6ecff83791 100644 --- a/scaddins/source/datefunc/datefunc.cxx +++ b/scaddins/source/datefunc/datefunc.cxx @@ -28,6 +28,7 @@ #include <unotools/resmgr.hxx> #include <i18nlangtag/languagetag.hxx> #include <algorithm> +#include <cmath> #include "deffuncname.hxx" using namespace ::com::sun::star; @@ -444,49 +445,19 @@ sal_Int32 GetNullDate( const uno::Reference< beans::XPropertySet >& xOptions ) * new Weeks(date1,date2,mode) function for StarCalc * * Two modes of operation are provided. - * The first is just a simple division by 7 calculation. + * mode 0 is just a simple division by 7 calculation. * - * The second calculates the difference by week of year. + * mode 1 calculates the difference by week adhering to ISO8601. * - * The International Standard IS-8601 has decreed that Monday - * shall be the first day of the week. - * - * A week that lies partly in one year and partly in another - * is assigned a number in the year in which most of its days lie. - * - * That means that week 1 of any year is the week that contains the 4. January - * - * The internal representation of a Date used in the Addin is the number of days based on 01/01/0001 - * - * A WeekDay can be then calculated by subtracting 1 and calculating the rest of - * a division by 7, which gives a 0 - 6 value for Monday - Sunday - * - * Using the 4. January rule explained above the formula - * - * nWeek1= ( nDays1 - nJan4 + ( (nJan4-1) % 7 ) ) / 7 + 1; - * - * calculates a number between 0-53 for each day which is in the same year as nJan4 - * where 0 means that this week belonged to the year before. - * - * If a day in the same or another year is used in this formula this calculates - * a calendar week offset from a given 4. January - * - * nWeek2 = ( nDays2 - nJan4 + ( (nJan4-1) % 7 ) ) / 7 + 1; - * - * The 4.January of first Date Argument can thus be used to calculate - * the week difference by calendar weeks which is then nWeek = nWeek2 - nWeek1 - * - * which can be optimized to + * The International Standard IS-8601 states that Monday is the first + * day of the week. The Gregorian Calender is used for all dates, + * proleptic in case of dates before 1582-10-15. * - * nWeek = ( (nDays2-nJan4+((nJan4-1)%7))/7 ) - ( (nDays1-nJan4+((nJan4-1)%7))/7 ) + * The (consecutive) week number of a date is + * std::floor( (date + NullDate - 1), 7.0 ), + * with weeks starting on Monday. * - * Note: All calculations are operating on the long integer data type - * % is the modulo operator in C which calculates the rest of an Integer division - * - * - * mode 0 is the interval between the dates in month, that is days / 7 - * - * mode 1 is the difference by week of year + * Weeks(d2,d1,m) is defined as -Weeks(d1,d2,m). * */ @@ -498,26 +469,18 @@ sal_Int32 SAL_CALL ScaDateAddIn::getDiffWeeks( if (nMode != 0 && nMode != 1) throw lang::IllegalArgumentException(); - sal_Int32 nNullDate = GetNullDate( xOptions ); - - sal_Int32 nDays1 = nStartDate + nNullDate; - sal_Int32 nDays2 = nEndDate + nNullDate; - - sal_Int32 nRet; - - if ( nMode == 1 ) + if ( nMode == 0 ) { - sal_uInt16 nDay,nMonth,nYear; - DaysToDate( nDays1, nDay, nMonth, nYear ); - sal_Int32 nJan4 = DateToDays( 4, 1, nYear ); - - nRet = ( (nDays2-nJan4+((nJan4-1)%7))/7 ) - ( (nDays1-nJan4+((nJan4-1)%7))/7 ); + return ( nEndDate - nStartDate ) / 7; } else { - nRet = (nDays2 - nDays1) / 7; + sal_Int32 nNullDate = GetNullDate( xOptions ); + sal_Int32 nDays1 = nStartDate + nNullDate - 1; + sal_Int32 nDays2 = nEndDate + nNullDate - 1; + + return ( std::floor( nDays2 / 7.0 ) - std::floor( nDays1 / 7.0 ) ); } - return nRet; } /** |