Package org.jruby.ext.date
Class RubyDate
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.ext.date.RubyDate
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<IRubyObject>,InstanceVariables,InternalVariables,IRubyObject,CoreObjectType
- Direct Known Subclasses:
RubyDateTime
JRuby's
Date implementation - 'native' parts.
In MRI, since 2.x, all of date.rb has been moved to native (C) code.
NOTE: There's still date.rb, where this gets bootstrapped from.- Since:
- 9.2
- Author:
- enebo, kares
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.DataNested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer -
Field Summary
Fields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATORFields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStampFields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY -
Constructor Summary
ConstructorsModifierConstructorDescriptionDeprecated.Deprecated.protectedRubyDate(ThreadContext context, long millis, org.joda.time.Chronology chronology) -
Method Summary
Modifier and TypeMethodDescriptionstatic RubyInteger_comp_year69(ThreadContext context, IRubyObject self, IRubyObject year) static RubyInteger_i(ThreadContext context, IRubyObject self, IRubyObject val) static RubyDate_load(ThreadContext context, IRubyObject klass, IRubyObject str) static IRubyObject_match(ThreadContext context, IRubyObject self, IRubyObject reg, IRubyObject str) static IRubyObject_parse_ddd(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject h) static IRubyObject_parse_impl(ThreadContext context, IRubyObject self, IRubyObject s, IRubyObject h) static IRubyObject_parse_iso2(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject h) static IRubyObject_parse_jis(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject h) static IRubyObject_parse_vms(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject h) static IRubyObject_s3e(ThreadContext context, IRubyObject self, IRubyObject[] args) static IRubyObject_strptime(ThreadContext context, IRubyObject self, IRubyObject string) static IRubyObject_strptime(ThreadContext context, IRubyObject self, IRubyObject[] args) static IRubyObject_strptime(ThreadContext context, IRubyObject self, IRubyObject string, IRubyObject format) static IRubyObject_subs(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject reg) _valid_civil_p(ThreadContext context, IRubyObject[] args) Deprecated.static IRubyObject_valid_civil_p(ThreadContext context, IRubyObject self, IRubyObject[] args) static IRubyObject_valid_commercial_p(ThreadContext context, IRubyObject self, IRubyObject[] args) Deprecated.static IRubyObject_valid_jd_p(IRubyObject self, IRubyObject jd) static IRubyObject_valid_jd_p(IRubyObject self, IRubyObject jd, IRubyObject sg) _valid_ordinal_p(ThreadContext context, IRubyObject[] args) Deprecated.static IRubyObject_valid_ordinal_p(ThreadContext context, IRubyObject self, IRubyObject[] args) Deprecated.static IRubyObject_valid_time_p(ThreadContext context, IRubyObject self, IRubyObject h, IRubyObject m, IRubyObject s) static IRubyObject_valid_weeknum_p(ThreadContext context, IRubyObject self, IRubyObject[] args) Deprecated.ajd(ThreadContext context) amjd(ThreadContext context) static RubyDatecivil(ThreadContext context, IRubyObject self) # Create a new Date object for the Civil Date specified by # year +y+, month +m+, and day-of-month +d+.static RubyDatecivil(ThreadContext context, IRubyObject self, IRubyObject year) static RubyDatecivil(ThreadContext context, IRubyObject self, IRubyObject[] args) static RubyDatecivil(ThreadContext context, IRubyObject self, IRubyObject year, IRubyObject month) static RubyDatecivil(ThreadContext context, IRubyObject self, IRubyObject year, IRubyObject month, IRubyObject mday) static org.joda.time.DateTimecivilDate(ThreadContext context, int y, int m, int d, org.joda.time.Chronology chronology) static RubyDatecommercial(ThreadContext context, IRubyObject self, IRubyObject[] args) cwday(ThreadContext context) cweek(ThreadContext context) cwyear(ThreadContext context) day_fraction(ThreadContext context) england(ThreadContext context) eql_p(ThreadContext context, IRubyObject other) booleanThis override does not do a "checked" dispatch.final booleanstatic org.joda.time.ChronologygetChronology(ThreadContext context, long sg, int off) org.joda.time.DateTimeintgetDay()intgetHour()Will return the Java interface that most closely can represent this object, when working through Java integration translations.final longintintgetMonth()intgetNanos()intintgetYear()gregorian(ThreadContext context) static IRubyObjectgregorian_leap_p(ThreadContext context, IRubyObject self, IRubyObject year) gregorian_p(ThreadContext context) hash(ThreadContext context) Will return the hash code of this object.inthashCode()This override does not do "checked" dispatch since Object usually has #hash defined.hour(ThreadContext context) initialize(ThreadContext context, IRubyObject dt) Deprecated.kept due AR-JDBC (uses RubyClass.newInstance(...) to 'fast' allocate a Date instance)initialize(ThreadContext context, IRubyObject ajd, IRubyObject of) initialize(ThreadContext context, IRubyObject ajd, IRubyObject of, IRubyObject sg) initialize_copy(ThreadContext context, IRubyObject original) Initializes this object as a copy of the original, that is the parameter to this object.inspect(ThreadContext context) Returns a string containing a human-readable representation of obj.final booleanisJulian()italy(ThreadContext context) jd(ThreadContext context) static RubyDatejd(ThreadContext context, IRubyObject self) Create a new Date object from a Julian Day Number.static RubyDatejd(ThreadContext context, IRubyObject self, IRubyObject jd) static RubyDatejd(ThreadContext context, IRubyObject self, IRubyObject jd, IRubyObject sg) static RubyNumericjd_to_ajd(ThreadContext context, IRubyObject self, IRubyObject[] args) julian(ThreadContext context) static IRubyObjectjulian_leap_p(ThreadContext context, IRubyObject self, IRubyObject year) julian_p(ThreadContext context) ld(ThreadContext context) leap_p(ThreadContext context) marshal_dump(ThreadContext context) marshal_load(ThreadContext context, IRubyObject a) mday(ThreadContext context) minute(ThreadContext context) mjd(ThreadContext context) mon(ThreadContext context) static RubyDatenew_(ThreadContext context, IRubyObject self) Deprecated.internal Date.new!static RubyDatenew_(ThreadContext context, IRubyObject self, IRubyObject ajd) Deprecated.internal Date.new!static RubyDatenew_(ThreadContext context, IRubyObject self, IRubyObject ajd, IRubyObject of) Deprecated.internal Date.new!static RubyDatenew_(ThreadContext context, IRubyObject self, IRubyObject ajd, IRubyObject of, IRubyObject sg) Deprecated.internal Date.new!new_offset(ThreadContext context, IRubyObject[] args) new_start(ThreadContext context) new_start(ThreadContext context, IRubyObject sg) next(ThreadContext context) next_day(ThreadContext context) next_day(ThreadContext context, IRubyObject n) next_month(ThreadContext context) next_month(ThreadContext context, IRubyObject n) next_year(ThreadContext context) next_year(ThreadContext context, IRubyObject n) offset(ThreadContext context) op_cmp(ThreadContext context, IRubyObject other) op_eqq(ThreadContext context, IRubyObject other) The relationship operator for Date.op_minus(ThreadContext context, IRubyObject n) op_plus(ThreadContext context, IRubyObject n) static RubyDateordinal(ThreadContext context, IRubyObject self, IRubyObject[] args) prev_day(ThreadContext context) prev_day(ThreadContext context, IRubyObject n) prev_month(ThreadContext context) prev_month(ThreadContext context, IRubyObject n) prev_year(ThreadContext context) prev_year(ThreadContext context, IRubyObject n) sec_fraction(ThreadContext context) second(ThreadContext context) shift_bw(ThreadContext context, IRubyObject n) shift_fw(ThreadContext context, IRubyObject n) start(ThreadContext context) strftime(ThreadContext context) strftime(ThreadContext context, IRubyObject fmt) to_date()to_datetime(ThreadContext context) to_s(ThreadContext context) to_time(ThreadContext context) toDate()static RubyDatetoday(ThreadContext context, IRubyObject self) # Create a new Date object representing today.static RubyDatetoday(ThreadContext context, IRubyObject self, IRubyObject sg) <T> TConvert the object to the specified Java class, if possible.static IRubyObjectvalid_civil_p(ThreadContext context, IRubyObject self, IRubyObject[] args) static IRubyObjectvalid_commercial_p(ThreadContext context, IRubyObject self, IRubyObject[] args) static IRubyObjectvalid_jd_p(ThreadContext context, IRubyObject self, IRubyObject jd) static IRubyObjectvalid_jd_p(ThreadContext context, IRubyObject self, IRubyObject jd, IRubyObject sg) static IRubyObjectvalid_ordinal_p(ThreadContext context, IRubyObject self, IRubyObject[] args) wday(ThreadContext context) yday(ThreadContext context) year(ThreadContext context) zone(ThreadContext context) static IRubyObjectzone_to_diff(ThreadContext context, IRubyObject self, IRubyObject zone) Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, dig, dig1, dig2, eqlInternal, equalInternal, finishObjectClass, getNativeClassIndex, inspect, puts, specificEval, toRubyString, toStringMethods inherited from class org.jruby.RubyBasicObject
addFinalizer, addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, cloneSetup, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, display, dup, dupFinalizer, dupSetup, ensureInstanceVariablesSettable, eql, eql_p, equal_p, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, finishBasicObjectClass, forEachInstanceVariable, forEachInstanceVariableName, freeze, frozen_p, getCurrentContext, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getMarshalVariableList, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize_copy, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, makeMetaClass, makeMetaClassBootstrap, method, method, method, method_missing, methods, methods, nil_p, nonFixnumHashCode, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_equal, op_match, op_not, op_not_equal, op_not_match, private_methods, protected_methods, public_methods, rbClone, rbClone, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method, singleton_method_added, singleton_method_removed, singleton_method_undefined, singleton_methods, singletonClass, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_a, to_s, trust, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnderMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jruby.runtime.builtin.IRubyObject
checkStringType19, dup, marshalLiveVariables
-
Constructor Details
-
RubyDate
-
RubyDate
-
RubyDate
Deprecated. -
RubyDate
@Deprecated(since="10.0") public RubyDate(Ruby runtime, long millis, org.joda.time.Chronology chronology) Deprecated. -
RubyDate
-
-
Method Details
-
initialize
Deprecated.kept due AR-JDBC (uses RubyClass.newInstance(...) to 'fast' allocate a Date instance)Note: since
Date.newis acivilalias, this won't ever get used -
initialize
-
initialize
-
initialize_copy
Description copied from class:RubyBasicObjectInitializes this object as a copy of the original, that is the parameter to this object. Will make sure that the argument actually has the same real class as this object. It shouldn't be possible to initialize an object with something totally different.- Overrides:
initialize_copyin classRubyBasicObject- Parameters:
context- the thread contextoriginal- the original- Returns:
- a copy unless the same thing
-
new_
Deprecated.internal Date.new! -
new_
@Deprecated(since="9.4-") public static RubyDate new_(ThreadContext context, IRubyObject self, IRubyObject ajd) Deprecated.internal Date.new! -
new_
@Deprecated(since="9.4-") public static RubyDate new_(ThreadContext context, IRubyObject self, IRubyObject ajd, IRubyObject of) Deprecated.internal Date.new! -
new_
@Deprecated(since="9.4-") public static RubyDate new_(ThreadContext context, IRubyObject self, IRubyObject ajd, IRubyObject of, IRubyObject sg) Deprecated.internal Date.new! -
civil
# Create a new Date object for the Civil Date specified by # year +y+, month +m+, and day-of-month +d+. # # +m+ and +d+ can be negative, in which case they count # backwards from the end of the year and the end of the # month respectively. No wraparound is performed, however, # and invalid values cause an ArgumentError to be raised. # can be negative # # +y+ defaults to -4712, +m+ to 1, and +d+ to 1; this is # Julian Day Number day 0. # # +sg+ specifies the Day of Calendar Reform. -
civil
-
civil
public static RubyDate civil(ThreadContext context, IRubyObject self, IRubyObject year, IRubyObject month) -
civil
public static RubyDate civil(ThreadContext context, IRubyObject self, IRubyObject year, IRubyObject month, IRubyObject mday) -
civil
-
civilDate
public static org.joda.time.DateTime civilDate(ThreadContext context, int y, int m, int d, org.joda.time.Chronology chronology) -
valid_civil_p
public static IRubyObject valid_civil_p(ThreadContext context, IRubyObject self, IRubyObject[] args) -
_valid_time_p
public static IRubyObject _valid_time_p(ThreadContext context, IRubyObject self, IRubyObject h, IRubyObject m, IRubyObject s) -
jd
Create a new Date object from a Julian Day Number. +jd+ is the Julian Day Number; if not specified, it defaults to 0. +sg+ specifies the Day of Calendar Reform. -
jd
-
jd
-
valid_jd_p
-
valid_jd_p
public static IRubyObject valid_jd_p(ThreadContext context, IRubyObject self, IRubyObject jd, IRubyObject sg) -
_valid_jd_p
-
_valid_jd_p
-
ordinal
-
valid_ordinal_p
public static IRubyObject valid_ordinal_p(ThreadContext context, IRubyObject self, IRubyObject[] args) -
_valid_ordinal_p
@Deprecated public static IRubyObject _valid_ordinal_p(ThreadContext context, IRubyObject self, IRubyObject[] args) Deprecated. -
_valid_ordinal_p
Deprecated. -
commercial
-
valid_commercial_p
public static IRubyObject valid_commercial_p(ThreadContext context, IRubyObject self, IRubyObject[] args) -
_valid_commercial_p
@Deprecated public static IRubyObject _valid_commercial_p(ThreadContext context, IRubyObject self, IRubyObject[] args) Deprecated. -
_valid_weeknum_p
@Deprecated public static IRubyObject _valid_weeknum_p(ThreadContext context, IRubyObject self, IRubyObject[] args) Deprecated. -
today
# Create a new Date object representing today. # # +sg+ specifies the Day of Calendar Reform. -
today
-
_valid_civil_p
public static IRubyObject _valid_civil_p(ThreadContext context, IRubyObject self, IRubyObject[] args) -
_valid_civil_p
Deprecated. -
getDateTime
public org.joda.time.DateTime getDateTime() -
equals
Description copied from class:RubyObjectThis override does not do a "checked" dispatch.- Overrides:
equalsin classRubyObject- Parameters:
other- object to compare- Returns:
- true if equals
- See Also:
-
equals
-
eql_p
- Overrides:
eql_pin classRubyBasicObject
-
op_eqq
The relationship operator for Date. Compares dates by Julian Day Number. When comparing two DateTime instances, or a DateTime with a Date, the instances will be regarded as equivalent if they fall on the same date in local time.- Specified by:
op_eqqin interfaceIRubyObject- Overrides:
op_eqqin classRubyObject- Parameters:
context-other-- Returns:
- true/false/nil
-
op_cmp
- Overrides:
op_cmpin classRubyBasicObject
-
hashCode
public int hashCode()Description copied from class:RubyObjectThis override does not do "checked" dispatch since Object usually has #hash defined.- Overrides:
hashCodein classRubyObject- Returns:
- the hash code
- See Also:
-
hash
Description copied from class:RubyBasicObjectWill return the hash code of this object. In comparison to MRI, this method will use the Java identity hash code instead of using rb_obj_id, since the usage of id in JRuby will incur the cost of some. ObjectSpace maintenance.- Overrides:
hashin classRubyBasicObject- Parameters:
context- the current thread context- Returns:
- the hash value
-
jd
-
getJulianDayNumber
public final long getJulianDayNumber() -
julian_p
-
gregorian_p
-
isJulian
public final boolean isJulian() -
ajd
-
amjd
-
start
-
year
-
yday
-
mon
-
mday
-
day_fraction
-
hour
-
minute
-
second
-
sec_fraction
-
cwyear
-
cweek
-
cwday
-
wday
-
zone
-
mjd
-
ld
-
offset
-
new_offset
-
new_start
-
new_start
-
italy
-
england
-
julian
-
gregorian
-
julian_leap_p
-
gregorian_leap_p
public static IRubyObject gregorian_leap_p(ThreadContext context, IRubyObject self, IRubyObject year) -
leap_p
-
op_plus
-
op_minus
-
next
-
next_day
-
next_day
-
prev_day
-
prev_day
-
next_month
-
next_month
-
prev_month
-
prev_month
-
shift_fw
-
shift_bw
-
next_year
-
next_year
-
prev_year
-
prev_year
-
marshal_dump
-
_load
-
marshal_load
-
jd_to_ajd
-
getChronology
-
inspect
Description copied from class:RubyBasicObjectReturns a string containing a human-readable representation of obj. If not overridden, uses theto_smethod to generate the string. [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"- Specified by:
inspectin interfaceIRubyObject- Overrides:
inspectin classRubyBasicObject
-
to_s
- Overrides:
to_sin classRubyBasicObject
-
to_date
-
to_datetime
-
to_time
-
strftime
-
strftime
-
_strptime
-
_strptime
public static IRubyObject _strptime(ThreadContext context, IRubyObject self, IRubyObject string, IRubyObject format) -
_strptime
-
zone_to_diff
-
_i
-
_comp_year69
-
_parse_jis
public static IRubyObject _parse_jis(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject h) -
_parse_vms
public static IRubyObject _parse_vms(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject h) -
_parse_iso2
public static IRubyObject _parse_iso2(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject h) -
_parse_ddd
public static IRubyObject _parse_ddd(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject h) -
_parse_impl
public static IRubyObject _parse_impl(ThreadContext context, IRubyObject self, IRubyObject s, IRubyObject h) -
_subs
public static IRubyObject _subs(ThreadContext context, IRubyObject self, IRubyObject str, IRubyObject reg) -
_match
public static IRubyObject _match(ThreadContext context, IRubyObject self, IRubyObject reg, IRubyObject str) -
_s3e
-
getYear
public int getYear()- Returns:
- year
-
getMonth
public int getMonth()- Returns:
- month-of-year (1..12)
-
getDay
public int getDay()- Returns:
- day-of-month
-
getHour
public int getHour()- Returns:
- hour-of-day (0..23)
-
getMinute
public int getMinute()- Returns:
- minute-of-hour
-
getSecond
public int getSecond()- Returns:
- second-of-minute
-
getNanos
public int getNanos()- Returns:
- the nano second part (only) of time
-
toDate
-
toInstant
- Returns:
- an instant
-
toLocalDate
- Returns:
- a (local) date
-
getJavaClass
Description copied from class:RubyBasicObjectWill return the Java interface that most closely can represent this object, when working through Java integration translations.- Specified by:
getJavaClassin interfaceIRubyObject- Overrides:
getJavaClassin classRubyBasicObject- Returns:
- the true Java class of this (Ruby) object
-
toJava
Description copied from interface:IRubyObjectConvert the object to the specified Java class, if possible.- Specified by:
toJavain interfaceIRubyObject- Overrides:
toJavain classRubyBasicObject- Type Parameters:
T- type- Parameters:
target- The target type to which the object should be converted.- Returns:
- java type
- See Also:
-