WoY() - Harbour bug

Harbour, MingW related news.

Moderator: Rathinagiri

Post Reply
User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 176 times

WoY() - Harbour bug

Post by Pablo César » Thu Dec 15, 2016 12:01 am

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 3545 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. :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 176 times

Post by Pablo César » Thu Dec 15, 2016 1:09 am

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 ...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
mol
Posts: 2801
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 112 times
Been thanked: 52 times
Contact:

Post by mol » Thu Dec 15, 2016 6:38 am

Thanks Pablo for your good work!

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

User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 176 times

Post by Pablo César » Thu Dec 15, 2016 9:07 am

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 ...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

KDJ
Posts: 164
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 148 times

Post by KDJ » Sat Dec 17, 2016 1:36 pm

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.

User avatar
Pablo César
Posts: 4058
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 176 times

Post by Pablo César » Sat Dec 17, 2016 7:55 pm

Yes Krzysztof, Przemyslaw has fixed. :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

Post Reply