Welcome Guest, Not a member yet? Register   Sign In
a little bug in days_in_month() function !
#1

[eluser]josepichu[/eluser]
Hi!

I have found a little bug in days_in_month($month, $year) helper function.

I Agugust and September months, i have to write the month without a zero.
for example, if you write:

Code:
days_in_month(08,2012) // the function return '0'
days_in_month(8,2012) // the function return '31'

days_in_month(09,2012) // the function return '0'
days_in_month(9,2012) // the function return '30'

In the other months there is not problem with the zero.

a greeting.
#2

[eluser]InsiteFX[/eluser]
It's not a bug, php removes the leading 0's. To php they are just null values.

#3

[eluser]Stefan Hueg[/eluser]
No he is correct, the behaviour is strange: Try this:

Code:
if(01 < 1 OR 01 > 12)
   echo '01 ';
  if(02 < 1 OR 02 > 12)
   echo '02 ';
  if(03 < 1 OR 03 > 12)
   echo '03 ';
  if(04 < 1 OR 04 > 12)
   echo '04 ';
  if(05 < 1 OR 05 > 12)
   echo '05 ';
  if(06 < 1 OR 06 > 12)
   echo '06 ';
  if(07 < 1 OR 07 > 12)
   echo '07 ';
  if(08 < 1 OR 08 > 12)
   echo '08 ';
  if(09 < 1 OR 09 > 12)
   echo '09 ';
  if(10 < 1 OR 10 > 12)
   echo '10 ';
  if(11 < 1 OR 11 > 12)
   echo '11 ';
  if(12 < 1 OR 12 > 12)
   echo '12 ';

But its PHP-related and has nothing to do with CodeIgniter.
#4

[eluser]josepichu[/eluser]
Thanks Smile.
#5

[eluser]Stefan Hueg[/eluser]
[quote author="InsiteFX" date="1335786780"]It's not a bug, php removes the leading 0's. To php they are just null values.

[/quote]

False. I found the answer.

01, 02, 03, 04 etc. are octal notation.

As there is no 08 or 09 in octal notation, the checks fail.




Theme © iAndrew 2016 - Forum software by © MyBB