Skip to content
Browse files

Optimization for isLeapYear. It showed to be 300 times faster (no jok…

…e) than the old one.

The implementation is based on: http://en.wikipedia.org/wiki/Leap_year
  • Loading branch information...
1 parent d71e6ee commit 6a79351c602a22390cac7b4c9e4634b59f8821d3 Fábio M. Costa committed
Showing with 1 addition and 1 deletion.
  1. +1 −1 Source/Native/Date.js
View
2 Source/Native/Date.js
@@ -277,7 +277,7 @@ Date.extend({
},
isLeapYear: function(year){
- return new Date(year, 1, 29).get('date') == 29;
+ return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0);
},
parse: function(from){

0 comments on commit 6a79351

Please sign in to comment.
Something went wrong with that request. Please try again.