Skip to content

Commit 62a3dd6

Browse files
committed
Restore internal Date methods still used by date.rb
1 parent fcc5863 commit 62a3dd6

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

core/src/main/java/org/jruby/ext/date/RubyDate.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,22 @@ private static Long validOrdinalImpl(ThreadContext context, IRubyObject year, in
693693
return DateUtils._valid_ordinal_p(y, day, sg);
694694
}
695695

696+
@Deprecated(since = "9.2.0.0") // NOTE: should go away once no date.rb is using it
697+
@JRubyMethod(name = "_valid_ordinal?", meta = true, required = 2, optional = 1, checkArity = false, visibility = Visibility.PRIVATE)
698+
public static IRubyObject _valid_ordinal_p(ThreadContext context, IRubyObject self, IRubyObject[] args) {
699+
int argc = Arity.checkArgumentCount(context, args, 2, 3);
700+
701+
final long sg = argc > 2 ? val2sg(context, args[2]) : GREGORIAN;
702+
final Long jd = validOrdinalImpl(context, args[0], args[1], sg);
703+
return jd == null ? context.nil : asFixnum(context, jd);
704+
}
705+
706+
@Deprecated(since = "9.2.0.0") // NOTE: should go away once no date.rb is using it
707+
@JRubyMethod(name = "_valid_ordinal?", required = 2, optional = 1, checkArity = false, visibility = Visibility.PRIVATE)
708+
public IRubyObject _valid_ordinal_p(ThreadContext context, IRubyObject[] args) {
709+
return RubyDate._valid_ordinal_p(context, null, args);
710+
}
711+
696712
@JRubyMethod(name = "commercial", meta = true, optional = 4, checkArity = false)
697713
public static RubyDate commercial(ThreadContext context, IRubyObject self, IRubyObject[] args) {
698714
// commercial(y=-4712, w=1, d=1, sg=ITALY)
@@ -726,6 +742,30 @@ static Long validCommercialImpl(ThreadContext context, IRubyObject year, IRubyOb
726742
return DateUtils._valid_commercial_p(y, w, d, sg);
727743
}
728744

745+
@Deprecated(since = "9.2.0.0") // NOTE: should go away once no date.rb is using it
746+
@JRubyMethod(name = "_valid_commercial?", meta = true, required = 3, optional = 1, checkArity = false, visibility = Visibility.PRIVATE)
747+
public static IRubyObject _valid_commercial_p(ThreadContext context, IRubyObject self, IRubyObject[] args) {
748+
int argc = Arity.checkArgumentCount(context, args, 3, 4);
749+
750+
final long sg = argc > 3 ? val2sg(context, args[3]) : GREGORIAN;
751+
final Long jd = validCommercialImpl(context, args[0], args[1], args[2], sg);
752+
return jd == null ? context.nil : asFixnum(context, jd);
753+
}
754+
755+
@Deprecated(since = "9.2.0.0") // NOTE: should go away once no date.rb is using it
756+
@JRubyMethod(name = "_valid_weeknum?", meta = true, required = 4, optional = 1, checkArity = false, visibility = Visibility.PRIVATE)
757+
public static IRubyObject _valid_weeknum_p(ThreadContext context, IRubyObject self, IRubyObject[] args) {
758+
int argc = Arity.checkArgumentCount(context, args, 4, 5);
759+
760+
final long sg = argc > 4 ? val2sg(context, args[4]) : GREGORIAN;
761+
final int y = toInt(context, args[0]);
762+
final int w = toInt(context, args[1]);
763+
final int d = toInt(context, args[2]);
764+
final int f = toInt(context, args[3]);
765+
final Long jd = DateUtils._valid_weeknum_p(y, w, d, f, sg);
766+
return jd == null ? context.nil : asFixnum(context, jd);
767+
}
768+
729769
/**
730770
# Create a new Date object representing today.
731771
#
@@ -758,6 +798,12 @@ public static IRubyObject _valid_civil_p(ThreadContext context, IRubyObject self
758798
return jd == null ? context.nil : asFixnum(context, jd);
759799
}
760800

801+
@Deprecated(since = "9.2.0.0") // NOTE: should go away once no date.rb is using it
802+
@JRubyMethod(name = "_valid_civil?", required = 3, optional = 1, checkArity = false, visibility = Visibility.PRIVATE)
803+
public IRubyObject _valid_civil_p(ThreadContext context, IRubyObject[] args) {
804+
return RubyDate._valid_civil_p(context, null, args);
805+
}
806+
761807
public DateTime getDateTime() { return dt; }
762808

763809
@Override

0 commit comments

Comments
 (0)