Determinar si es año bisiesto
Por MigueliTUX Sep.09, 2009, categoría JavaScript
una pequeña función para determinar si es o no año bisiesto
//************************************************ // Determina si el año pasado como parámetro es o no bisiesto //************************************************ function esBisiesto(anio) { var BISIESTO; if(parseInt(anio)%4==0){ if(parseInt(anio)%100==0){ if(parseInt(anio)%400==0){ BISIESTO=true; } else{ BISIESTO=false; } } else{ BISIESTO=true; } } else BISIESTO=false; return BISIESTO; }
October 30th, 2009 on 1:38 pm
Las divisiones por 100 y 400 estarian demas en esta función, ya que todo número divisible por 100 y 400, es divisible por 4.
March 13th, 2010 on 2:05 pm
[...] si es añisiesto http://www.tips.cl/archives/482 #TipsCL [...]
April 24th, 2010 on 1:45 pm
[...] si es añisiesto http://www.tips.cl/archives/482 #TipsCL [...]
July 10th, 2010 on 1:46 pm
[...] si es añisiesto http://www.tips.cl/archives/482 #TipsCL [...]
August 12th, 2010 on 4:12 pm
de esta forma me gustó :
function esBisiesto(anio) {
var intAnio=(parseInt(anio));
var div4 = intAnio%4;
var div100 = intAnio%100;
return ((div4 && !div100) || ((div4 && div100) && (intAnio % 400==0)));
}