Posted By

root_hacker on 03/16/11


Tagged


Versions (?)

Leap Year Check In Javascript


 / Published in: JavaScript
 

date object return date of next month if day parameter overflows

  1. var month = {LastDay : function(Year,Month){ return 32 - new Date(Year,Month,32).getDate();}}
  2. var Year = {IsLeap: function(Year){ return 29 == month.LastDay(Year,1)}};
  3. Year.IsLeap(2000); // returns true
  4. Year.IsLeap(2000); // returns false

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: tomasdev on June 13, 2011

Year.IsLeap(2000); // returns true && false ?

You need to login to post a comment.