End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
Date.jd
Date.jd([jd=0[, start=Date::ITALY]]) → date
ext/date/date_core.c
View on GitHub ↗
static VALUE
date_s_jd(int argc, VALUE *argv, VALUE klass)
{
VALUE vjd, vsg, jd, fr, fr2, ret;
double sg;
rb_scan_args(argc, argv, "02", &vjd, &vsg);
jd = INT2FIX(0);
fr2 = INT2FIX(0);
sg = DEFAULT_SG;
switch (argc) {
case 2:
val2sg(vsg, sg);
case 1:
check_numeric(vjd, "jd");
num2num_with_frac(jd, positive_inf);
}
{
VALUE nth;
int rjd;
decode_jd(jd, &nth, &rjd);
ret = d_simple_new_internal(klass,
nth, rjd,
sg,
0, 0, 0,
HAVE_JD);
}
add_frac();
return ret;
}
Creates a date object denoting the given chronological Julian day number.
Example
Date.jd(2451944) #=> #<Date: 2001-02-03 ...> Date.jd(2451945) #=> #<Date: 2001-02-04 ...> Date.jd(0) #=> #<Date: -4712-01-01 ...>
See also ::new.