Page 1 of 1

WoY() - Harbour bug

Posted: Thu Dec 15, 2016 12:01 am
by Pablo César
Hi all, this is to inform we have found a bug in WoY() which is used to get the week number of the year for a given date.

Its syntax is: WoY( <dDate>, <lIso> ) -> nWeek
It returns ISO-based week number, i.e. in range 0..52, by default (or passing TRUE as second parameter), or in range 1..52 if lIso is FALSE.
But in this sample:

Code: Select all

Function Main
MsgBox(WoY(hb_CtoD("07-01-2017","dd-mm-yyyy"))) // 2 ?
Return
It's wrongly returning as week number 2. If you check in the 2017 calendar you will see that the right is week # 1.

Day 7 of January of 2017. Would it be the first week of the year by given that the week starts on Sunday. This was announced by Eduardo in this post. Others dates also can be with wrong result (for sure).

I found the probable error in the C function at:
Screen35.png
Screen35.png (47.6 KiB) Viewed 7388 times
I have translated all C functions envolved to PRG in case of replacement and my better understanding of the code.

I have already announced this bug at Harbour forum and we shall wait their return and fixing. Otherwise, we could provide the substitute function to fix this problem.

Keeping our community informed. :)

WoY() - Harbour bug

Posted: Thu Dec 15, 2016 1:09 am
by Pablo César
In my opinion, it is very important to always take time to report a possible bug. It's the only way to improve something.

I may even look boring man, but nowadays I lose some time but I report...

And if anyone gets offended or disturbed: I'm very sorry. I do my part, all in favor of improving our work tool, that's what matters and I think that same spirit altruism, almost every programmer xBase knows well that should share ...

Re: WoY() - Harbour bug

Posted: Thu Dec 15, 2016 6:38 am
by mol
Thanks Pablo for your good work!

But, it seems you justify yourself before you :-D

WoY() - Harbour bug

Posted: Thu Dec 15, 2016 9:07 am
by Pablo César
mol wrote:Thanks Pablo for your good work!

But, it seems you justify yourself before you :-D
Thank you. Yes, Marek sometimes I think I'm too boring to point out mistakes ... this time it's Harbor's mistake.
Maybe it's the enthusiasm I put in to instill others to do the same ...

It's also because sometimes I do not get an immediate response and then I think: Am I doing the right thing ?

But I am sure that my intention is never to belittle: on the contrary.

I respect the work of others, especially if it's something I'm using ...

Re: WoY() - Harbour bug

Posted: Sat Dec 17, 2016 1:36 pm
by KDJ
News:
Harbour changelog wrote:

Code: Select all

2016-12-16 11:05 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
  * contrib/hbmisc/dates.c
    ! fixed WOY() to return some reasonable results. I have no idea what
      author wanted to reach but now WOY() be default returns ISO 8601
      week number and simple week number if 2-nd parameter is .F.

WoY() - Harbour bug

Posted: Sat Dec 17, 2016 7:55 pm
by Pablo César
Yes Krzysztof, Przemyslaw has fixed. :)