AddDate Bug

Everything else that doesn't fall into one of the other PB categories.
DarkDragon
Addict
Addict
Posts: 2345
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

AddDate Bug

Post by DarkDragon »

Hey,

A german guy has found a bug(Charlie in the German Forum):

Code: Select all

Debug AddDate(ParseDate("%dd.%mm.%yyyy", "31.05.2005"), #PB_Date_Month, 1)
It doesn't work with increasingvalue 1, but with another value:

Code: Select all

Debug ParseDate("%dd.%mm.%yyyy", "31.05.2005")
Debug AddDate(ParseDate("%dd.%mm.%yyyy", "31.05.2005"), #PB_Date_Month, 2)
Debug FormatDate("%dd.%mm.%yyyy", AddDate(ParseDate("%dd.%mm.%yyyy", "31.05.2005"), #PB_Date_Month, 2))
bye,
Daniel
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: AddDate Bug

Post by traumatic »

There is no 31.06.2005 ! :)
(It also won't work with +4 etc.)
Good programmers don't comment their code. It was hard to write, should be hard to read.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Re: AddDate Bug

Post by thefool »

traumatic wrote:There is no 31.06.2005
:lol:
DarkDragon
Addict
Addict
Posts: 2345
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

OMG, why can't it be 1.7.2005 then?

btw.: by adding 2 to the month it is my next birthday ^^
Last edited by DarkDragon on Thu Mar 31, 2005 7:18 pm, edited 1 time in total.
bye,
Daniel
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

i just tried:

Code: Select all

Debug AddDate(ParseDate("%dd.%mm.%yyyy", "27.05.2005"), #PB_Date_Month, 1)

works perfectly :)

Code: Select all

Debug ParseDate("%dd.%mm.%yyyy", "20.05.2005")
Debug AddDate(ParseDate("%dd.%mm.%yyyy", "20.05.2005"), #PB_Date_Month, 2)
Debug FormatDate("%dd.%mm.%yyyy", AddDate(ParseDate("%dd.%mm.%yyyy", "20.05.2005"), #PB_Date_Month, 2))
works too :D
Charlie
New User
New User
Posts: 3
Joined: Sun Feb 27, 2005 11:45 am

Post by Charlie »

@traumatic
sure 31.06.2005 does not give, but why it can not return 30.06.2005 or 01.07.2005 as result?
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

AddDate() returns -1 meaning it's not a legal date.

If AddDate() was just adding 30 days, it would be up to the programmer
to check if it's a valid date. The date functions as they are implemented
by now save you all the "hard work" and make perfectly sense IMHO.

I do understand you want AddDate() to 'jump' to the next legal date but
there's the next question: Next day? Previous day?

I think it's better to leave the choice up to the programmer (read: you ;)).
Having a returnvalue of -1 it's fairly easy to code whatever behaviour you'd
expect your program to have.

Well, just my 2ct. but definitely not a bug.
Good programmers don't comment their code. It was hard to write, should be hard to read.
Post Reply