Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion core/src/main/java/org/jruby/ext/date/RubyDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,14 @@ private static boolean isJulianLeap(final long year) {
// All years divisible by 4 are leap years in the Gregorian calendar,
// except for years divisible by 100 and not by 400.
private static boolean isGregorianLeap(final long year) {
return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
long uy = (year >= 0) ? year : -year;
if ((uy & 3) != 0)
return false;

long century = uy / 100;
if (uy != century * 100)
return true;
return (century & 3) == 0;
}

@JRubyMethod(name = "leap?")
Expand Down