Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

Date.jd

Date.jd(jd = 0, start = Date::ITALY) → date

Returns a new Date object formed from the arguments:

Example
Date.jd(2451944).to_s # => "2001-02-03"
Date.jd(2451945).to_s # => "2001-02-04"
Date.jd(0).to_s       # => "-4712-01-01"

The returned date is:

  • Gregorian, if the argument is greater than or equal to start:

    Example
    Date::ITALY                         # => 2299161
    Date.jd(Date::ITALY).gregorian?     # => true
    Date.jd(Date::ITALY + 1).gregorian? # => true
    
  • Julian, otherwise

    Example
    Date.jd(Date::ITALY - 1).julian?    # => true
    

See argument start.

Related: Date.new.

See also #jd .iso8601 ._jisx0301 ._iso8601 also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0