idate problems

php.internals

Nuno Lopes

22 years ago
Hello, I've already reported this to the list some time ago, but nobody answered me until now. I think that the idate function has two little problems: 1) (i)date('L') should return the same (1 if is leap year, 0 otherwise), but they aren't outputing the same echo date('L'); //1 echo idate('L'); //0 2) idate('y') is supposed to return the year with *two*digits, althought it returns just 4. This can be fixed with a simple sprintf? Can somebody look at this, please? Thanks, Nuno

Christian Schneider

22 years ago
Nuno Lopes wrote:
> 1) (i)date('L') should return the same (1 if is leap year, 0 otherwise), but > they aren't outputing the same > echo date('L'); //1 > echo idate('L'); //0
Yes, this is indeed a bug in the isleap macro (you needed to call it with double parens), the fix is diff -u -r1.120 datetime.c --- ext/standard/datetime.c 31 Mar 2004 17:57:33 -0000 1.120 +++ ext/standard/datetime.c 24 Jun 2004 12:10:55 -0000 @@ -64,7 +64,7 @@ {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31} }; -#define isleap(year) (((year % 4) == 0 && (year % 100) != 0) || (year % 400)==0) +#define isleap(year) ((((year) % 4) == 0 && ((year) % 100) != 0) || ((year) % 400)==0) #define YEAR_BASE 1900 /* {{{ proto int time(void)
> 2) idate('y') is supposed to return the year with *two*digits, althought it > returns just 4. This can be fixed with a simple sprintf?
An integer cannot have leading zeros so the behaviour is correct. The documentation could be changed to reflect the fact the the integer value of the last two digits is returned, not the actual two digits (which would be a string and you should use date() for that). - Chris

Nuno Lopes

22 years ago
Any news on this? Can someone apply that patch or just add some () to the idate switch/case L ? Thanks, Nuno ----- Original Message -----
> Nuno Lopes wrote: > > 1) (i)date('L') should return the same (1 if is leap year, 0 otherwise),
but

Derick Rethans

22 years ago
On Mon, 28 Jun 2004, Nuno Lopes wrote:
> Any news on this? > Can someone apply that patch or just add some () to the idate switch/case L > ?
Done

Nuno Lopes

22 years ago
Thanks Derick!
> On Mon, 28 Jun 2004, Nuno Lopes wrote: > > > Any news on this? > > Can someone apply that patch or just add some () to the idate
switch/case L