Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
Date.valid_commercial?
(::Integer cwyear, ::Integer cweek, ::Integer cwday, ?::Integer start) -> bool
Date.valid_commercial?(cwyear, cweek, cwday, start = Date::ITALY) → true or false
ext/date/date_core.c
View on GitHub ↗
static VALUE
date_s_valid_commercial_p(int argc, VALUE *argv, VALUE klass)
{
VALUE vy, vw, vd, vsg;
VALUE argv2[4];
rb_scan_args(argc, argv, "31", &vy, &vw, &vd, &vsg);
RETURN_FALSE_UNLESS_NUMERIC(vy);
RETURN_FALSE_UNLESS_NUMERIC(vw);
RETURN_FALSE_UNLESS_NUMERIC(vd);
argv2[0] = vy;
argv2[1] = vw;
argv2[2] = vd;
if (argc < 4)
argv2[3] = INT2FIX(DEFAULT_SG);
else
argv2[3] = vsg;
if (NIL_P(valid_commercial_sub(4, argv2, klass, 0)))
return Qfalse;
return Qtrue;
}
Returns true if the arguments define a valid commercial date, false otherwise:
Example
Date.valid_commercial?(2001, 5, 6) # => true Date.valid_commercial?(2001, 5, 8) # => false
See Date.commercial.
See argument start.
Related: Date.jd, Date.commercial.