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:
- (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
- idate('y') is supposed to return the year with twodigits, althought it
returns just 4. This can be fixed with a simple sprintf?
Can somebody look at this, please?
Thanks,
Nuno
Nuno Lopes wrote:
- (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)
- idate('y') is supposed to return the year with twodigits, 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
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:
- (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'); //0Yes, this is indeed a bug in the isleap macro (you needed to call it
with double parens), the fix isdiff -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)
Chris
Any news on this?
Can someone apply that patch or just add some () to the idate switch/case L
?
Done
Thanks Derick!
Any news on this?
Can someone apply that patch or just add some () to the idate
switch/case L
?Done