Ruby – Get Julian Leap Year – Julian_leap?() Method – Examples & Explanation

The Julian leap method returns true if in the year in the given code is a leap year of the Proleptic Julian Calendar and false if not. The leap year comes after every 4 years. To get the Julian leap year you can use Date.julian_leap?() method.

julian_leap?() Method in Ruby

julian_leap?() method exists in Standard julian_leap? Library of Ruby. The purpose of this method is to get leap year from proleptic Julian Calendar.

 

Syntax of the julian_leap?() Method in Ruby

In date, the syntax of Julian leap method is:

Date.julian_leap?(x)

 

Parameter of julian_leap?() Method in Ruby

The parameter x is any valid Julian date object. This parameter is required.Note: If the x parameter is not a valid Julian date object julian_leap?() method will return an error.

 

Return Value of julian_leap?()

julian_leap?() method return the true if the year mentioned in the code is a leap year of proleptic Julian Calendar.

 

Ruby julian_leap?() Year Example 1

# import date library
require 'date'
x = Date.julian_leap?(2012)
puts x

Output
true

 

Ruby julian_leap?() Year Example 2

# import date library
require 'date'
x = Date.julian_leap?(2015)
puts x

Output
false

 

Ruby julian_leap?() Year Example 3

# import date library
require 'date'
x = Date.julian_leap?(2018)
puts x

Output
false

 

Ruby julian_leap?() Year Example 4

# import date library
require 'date'
x = Date.julian_leap?(2020)
puts x

Output
true