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.Data
Nested 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_ALLOCATOR
Fields 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, varTableStamp
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionDeprecated.Deprecated.protected
RubyDate
(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 RubyDate
civil
(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 RubyDate
civil
(ThreadContext context, IRubyObject self, IRubyObject year) static RubyDate
civil
(ThreadContext context, IRubyObject self, IRubyObject[] args) static RubyDate
civil
(ThreadContext context, IRubyObject self, IRubyObject year, IRubyObject month) static RubyDate
civil
(ThreadContext context, IRubyObject self, IRubyObject year, IRubyObject month, IRubyObject mday) static org.joda.time.DateTime
civilDate
(ThreadContext context, int y, int m, int d, org.joda.time.Chronology chronology) static RubyDate
commercial
(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) boolean
This override does not do a "checked" dispatch.final boolean
static org.joda.time.Chronology
getChronology
(ThreadContext context, long sg, int off) org.joda.time.DateTime
int
getDay()
int
getHour()
Will return the Java interface that most closely can represent this object, when working through Java integration translations.final long
int
int
getMonth()
int
getNanos()
int
int
getYear()
gregorian
(ThreadContext context) static IRubyObject
gregorian_leap_p
(ThreadContext context, IRubyObject self, IRubyObject year) gregorian_p
(ThreadContext context) hash
(ThreadContext context) Will return the hash code of this object.int
hashCode()
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 boolean
isJulian()
italy
(ThreadContext context) jd
(ThreadContext context) static RubyDate
jd
(ThreadContext context, IRubyObject self) Create a new Date object from a Julian Day Number.static RubyDate
jd
(ThreadContext context, IRubyObject self, IRubyObject jd) static RubyDate
jd
(ThreadContext context, IRubyObject self, IRubyObject jd, IRubyObject sg) static RubyNumeric
jd_to_ajd
(ThreadContext context, IRubyObject self, IRubyObject[] args) julian
(ThreadContext context) static IRubyObject
julian_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 RubyDate
new_
(ThreadContext context, IRubyObject self) Deprecated.internal Date.new!static RubyDate
new_
(ThreadContext context, IRubyObject self, IRubyObject ajd) Deprecated.internal Date.new!static RubyDate
new_
(ThreadContext context, IRubyObject self, IRubyObject ajd, IRubyObject of) Deprecated.internal Date.new!static RubyDate
new_
(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 RubyDate
ordinal
(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 RubyDate
today
(ThreadContext context, IRubyObject self) # Create a new Date object representing today.static RubyDate
today
(ThreadContext context, IRubyObject self, IRubyObject sg) <T> T
Convert the object to the specified Java class, if possible.static IRubyObject
valid_civil_p
(ThreadContext context, IRubyObject self, IRubyObject[] args) static IRubyObject
valid_commercial_p
(ThreadContext context, IRubyObject self, IRubyObject[] args) static IRubyObject
valid_jd_p
(ThreadContext context, IRubyObject self, IRubyObject jd) static IRubyObject
valid_jd_p
(ThreadContext context, IRubyObject self, IRubyObject jd, IRubyObject sg) static IRubyObject
valid_ordinal_p
(ThreadContext context, IRubyObject self, IRubyObject[] args) wday
(ThreadContext context) yday
(ThreadContext context) year
(ThreadContext context) zone
(ThreadContext context) static IRubyObject
zone_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, toString
Methods 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, yieldUnder
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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.new
is acivil
alias, this won't ever get used -
initialize
-
initialize
-
initialize_copy
Description copied from class:RubyBasicObject
Initializes 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_copy
in 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:RubyObject
This override does not do a "checked" dispatch.- Overrides:
equals
in classRubyObject
- Parameters:
other
- object to compare- Returns:
- true if equals
- See Also:
-
equals
-
eql_p
- Overrides:
eql_p
in 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_eqq
in interfaceIRubyObject
- Overrides:
op_eqq
in classRubyObject
- Parameters:
context
-other
-- Returns:
- true/false/nil
-
op_cmp
- Overrides:
op_cmp
in classRubyBasicObject
-
hashCode
public int hashCode()Description copied from class:RubyObject
This override does not do "checked" dispatch since Object usually has #hash defined.- Overrides:
hashCode
in classRubyObject
- Returns:
- the hash code
- See Also:
-
hash
Description copied from class:RubyBasicObject
Will 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:
hash
in 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:RubyBasicObject
Returns a string containing a human-readable representation of obj. If not overridden, uses theto_s
method 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:
inspect
in interfaceIRubyObject
- Overrides:
inspect
in classRubyBasicObject
-
to_s
- Overrides:
to_s
in 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:RubyBasicObject
Will return the Java interface that most closely can represent this object, when working through Java integration translations.- Specified by:
getJavaClass
in interfaceIRubyObject
- Overrides:
getJavaClass
in classRubyBasicObject
- Returns:
- the true Java class of this (Ruby) object
-
toJava
Description copied from interface:IRubyObject
Convert the object to the specified Java class, if possible.- Specified by:
toJava
in interfaceIRubyObject
- Overrides:
toJava
in classRubyBasicObject
- Type Parameters:
T
- type- Parameters:
target
- The target type to which the object should be converted.- Returns:
- java type
- See Also:
-