Method: Date.jd
- Defined in:
- date_core.c
.jd(jd = 0, start = Date::ITALY) ⇒ Object
Returns a new Date object formed from the arguments:
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:Date::ITALY # => 2299161 Date.jd(Date::ITALY).gregorian? # => true Date.jd(Date::ITALY + 1).gregorian? # => true -
Julian, otherwise
Date.jd(Date::ITALY - 1).julian? # => true
See argument start.
Related: Date.new.
3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 |
# File 'date_core.c', line 3357 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; } |