Package org.jruby.ext.date
Class RubyDateTime
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.ext.date.RubyDate
org.jruby.ext.date.RubyDateTime
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<IRubyObject>,InstanceVariables,InternalVariables,IRubyObject,CoreObjectType
JRuby's
DateTime 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
- 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
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final ByteListprivate static final ByteListFields inherited from class org.jruby.ext.date.RubyDate
CHRONO_ITALY_UTC, DAY_IN_SECONDS, DAY_MS, defaultDateTime, dt, ENGLAND, GREGORIAN, ITALY, JULIAN, LOG, off, REFORM_BEGIN_YEAR, REFORM_END_YEAR, start, SUB_MS_PRECISION, subMillisDen, subMillisNumFields 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, UNTRUST_F, 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
ConstructorsModifierConstructorDescriptionRubyDateTime(Ruby runtime, long millis, org.joda.time.Chronology chronology) RubyDateTime(Ruby runtime, org.joda.time.DateTime dt) protectedRubyDateTime(Ruby runtime, RubyClass klass) RubyDateTime(Ruby runtime, RubyClass klass, org.joda.time.DateTime dt) privateRubyDateTime(Ruby runtime, RubyClass klass, org.joda.time.DateTime dt, int off) (package private)RubyDateTime(Ruby runtime, RubyClass klass, org.joda.time.DateTime dt, int off, long start) (package private)RubyDateTime(Ruby runtime, RubyClass klass, org.joda.time.DateTime dt, int off, long start, long subMillisNum, long subMillisDen) (package private)RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, int off, long start) privateRubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, long[] rest, int off, long start) (package private)RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, org.joda.time.Chronology chronology, int off) -
Method Summary
Modifier and TypeMethodDescriptionstatic IRubyObject_strptime(ThreadContext context, IRubyObject self, IRubyObject string) static IRubyObject_strptime(ThreadContext context, IRubyObject self, IRubyObject string, IRubyObject format) private static voidaddFraction(ThreadContext context, long[] rest, RubyNumeric fr, boolean roundFloat) private static voidaddRationalModToRest(ThreadContext context, RubyRational rat, long ival, long[] rest) private static voidaddRationalModToRest(ThreadContext context, IRubyObject val, long ival, long[] rest) private static voidassertValidFraction(ThreadContext context, IRubyObject val, long ival) private static voidcalcBigIntDayRest(RubyRational day, long d, long[] rest) static RubyDateTimecivil(ThreadContext context, IRubyObject self) # Create a new DateTime object corresponding to the specified # Civil Date and hour +h+, minute +min+, second +s+.static RubyDateTimecivil(ThreadContext context, IRubyObject self, IRubyObject year) static RubyDateTimecivil(ThreadContext context, IRubyObject self, IRubyObject[] args) static RubyDateTimecivil(ThreadContext context, IRubyObject self, IRubyObject year, IRubyObject month) (package private) static RubyClasscreateDateTimeClass(Ruby runtime, RubyClass Date) (package private) static longgetDay(ThreadContext context, IRubyObject day, long[] rest) (package private) static intgetHour(ThreadContext context, IRubyObject hour, long[] rest) (package private) static intgetMinute(ThreadContext context, IRubyObject val, long[] rest) (package private) static intgetSecond(ThreadContext context, IRubyObject val, long[] rest) static RubyDateTimejd(ThreadContext context, IRubyObject self) # Create a new DateTime object corresponding to the specified # Julian Day Number +jd+ and hour +h+, minute +min+, second +s+.static RubyDateTimejd(ThreadContext context, IRubyObject self, IRubyObject[] args) (package private) RubyDatenewInstance(ThreadContext context, org.joda.time.DateTime dt, int off, long start, long subNum, long subDen) next_day(ThreadContext context, IRubyObject n) static RubyDateTimenow(ThreadContext context, IRubyObject self) # Create a new DateTime object representing the current time.static RubyDateTimenow(ThreadContext context, IRubyObject self, IRubyObject sg) prev_day(ThreadContext context, IRubyObject n) private RubyDateprevNextDay(ThreadContext context, IRubyObject n, boolean negate) strftime(ThreadContext context) strftime(ThreadContext context, IRubyObject fmt) to_date(ThreadContext context) to_s(ThreadContext context) to_time(ThreadContext context) <T> TConvert the object to the specified Java class, if possible.(package private) static org.joda.time.DateTimewithTimeAt0InZone(org.joda.time.DateTime dt, org.joda.time.DateTimeZone zone) Methods inherited from class org.jruby.ext.date.RubyDate
_comp_year69, _i, _load, _match, _parse_day, _parse_ddd, _parse_dot, _parse_eu, _parse_impl, _parse_iso, _parse_iso2, _parse_jis, _parse_mday, _parse_mon, _parse_sla, _parse_time, _parse_us, _parse_vms, _parse_year, _s3e, _strptime, _subs, _valid_civil_p, _valid_civil_p, _valid_commercial_p, _valid_jd_p, _valid_jd_p, _valid_ordinal_p, _valid_ordinal_p, _valid_time_p, _valid_weeknum_p, adjustJodaYear, ajd, amjd, civil, civilDate, civilImpl, civilImpl, commercial, createDateClass, cwday, cweek, cwyear, day_fraction, debug, england, eql_p, equals, equals, format, getChronology, getChronology, getDate, getDateTime, getDateTime, getDay, getHour, getJavaClass, getJulianDayNumber, getMinute, getMonth, getMonth, getNanos, getSecond, getValidStart, getYear, getYear, gregorian, gregorian_leap_p, gregorian_p, hash, hash, hashCode, hour, initialize, initialize, initialize, initialize_copy, inspect, inspect, isJulian, italy, jd, jd, jd, jd_to_ajd, jd_to_ajd, jd_to_ajd, jd_to_ajd, julian, julian_leap_p, julian_p, ld, leap_p, marshal_dump, marshal_load, mday, minute, mjd, mon, new_, new_, new_, new_, new_offset, new_start, new_start, newInstance, newRationalConvert, next, next_day, next_month, next_month, next_year, next_year, normalizeSubMillis, offset, op_cmp, op_eqq, op_minus, op_plus, op_plus_numeric, ordinal, parse, parse_bc, parse_frag, prev_day, prev_month, prev_month, prev_year, prev_year, roundToPrecision, sec_fraction, second, shift_bw, shift_fw, start, subMillis, timesIntDiff, timeToDayFraction, to_date, to_datetime, to_s, toDate, today, today, toInstant, toLocalDate, val2off, val2sg, valid_civil_p, valid_commercial_p, valid_jd_p, valid_jd_p, valid_ordinal_p, valid_sg, validCivilImpl, validCommercialImpl, validOrdinalImpl, wday, yday, year, zone, zone_to_diffMethods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, dig, dig1, dig2, eqlInternal, equalInternal, getNativeClassIndex, inspect, puts, specificEval, toRubyString, toStringMethods inherited from class org.jruby.RubyBasicObject
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, display, dup, ensureInstanceVariablesSettable, eql, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize19, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method, method_missing, method_missing19, method19, methods, methods, methods19, nil_p, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_equal, op_equal_19, op_match, op_match19, op_not, op_not_equal, op_not_match, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, rbClone, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method_added, singleton_method_added19, singleton_method_removed, singleton_method_removed19, singleton_method_undefined, singleton_method_undefined19, singleton_methods, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_a, trust, type, type_deprecated, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
-
Field Details
-
TO_S_FORMAT
-
STRF_FORMAT_BYTES
-
DEFAULT_FORMAT
- See Also:
-
-
Constructor Details
-
RubyDateTime
-
RubyDateTime
-
RubyDateTime
-
RubyDateTime
-
RubyDateTime
RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, int off, long start) -
RubyDateTime
private RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, long[] rest, int off, long start) -
RubyDateTime
-
RubyDateTime
-
RubyDateTime
-
RubyDateTime
RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, org.joda.time.Chronology chronology, int off)
-
-
Method Details
-
createDateTimeClass
-
newInstance
RubyDate newInstance(ThreadContext context, org.joda.time.DateTime dt, int off, long start, long subNum, long subDen) - Overrides:
newInstancein classRubyDate
-
civil
# Create a new DateTime object corresponding to the specified # Civil Date and hour +h+, minute +min+, second +s+. # # The 24-hour clock is used. Negative values of +h+, +min+, and # +sec+ are treating as counting backwards from the end of the # next larger unit (e.g. a +min+ of -2 is treated as 58). No # wraparound is performed. If an invalid time portion is specified, # an ArgumentError is raised. # # +of+ is the offset from UTC as a fraction of a day (defaults to 0). # +sg+ specifies the Day of Calendar Reform. # # +y+ defaults to -4712, +m+ to 1, and +d+ to 1; this is Julian Day # Number day 0. The time values default to 0. -
civil
-
civil
public static RubyDateTime civil(ThreadContext context, IRubyObject self, IRubyObject year, IRubyObject month) -
civil
-
getDay
-
calcBigIntDayRest
-
getHour
-
getMinute
-
getSecond
-
addRationalModToRest
private static void addRationalModToRest(ThreadContext context, IRubyObject val, long ival, long[] rest) -
addRationalModToRest
private static void addRationalModToRest(ThreadContext context, RubyRational rat, long ival, long[] rest) -
addFraction
private static void addFraction(ThreadContext context, long[] rest, RubyNumeric fr, boolean roundFloat) -
assertValidFraction
-
jd
# Create a new DateTime object corresponding to the specified # Julian Day Number +jd+ and hour +h+, minute +min+, second +s+. # # The 24-hour clock is used. Negative values of +h+, +min+, and # +sec+ are treating as counting backwards from the end of the # next larger unit (e.g. a +min+ of -2 is treated as 58). No # wraparound is performed. If an invalid time portion is specified, # an ArgumentError is raised. # # +of+ is the offset from UTC as a fraction of a day (defaults to 0). # +sg+ specifies the Day of Calendar Reform. # # All day/time values default to 0. -
jd
-
now
# Create a new DateTime object representing the current time. # # +sg+ specifies the Day of Calendar Reform. -
now
-
prev_day
-
next_day
-
prevNextDay
-
to_s
-
to_date
-
withTimeAt0InZone
static org.joda.time.DateTime withTimeAt0InZone(org.joda.time.DateTime dt, org.joda.time.DateTimeZone zone) -
to_datetime
-
to_time
-
strftime
-
strftime
-
_strptime
-
_strptime
public static IRubyObject _strptime(ThreadContext context, IRubyObject self, IRubyObject string, IRubyObject format) -
toLocalDateTime
- Returns:
- a date time
-
toZonedDateTime
- Returns:
- a date time
-
toOffsetDateTime
- Returns:
- a date time
-
toJava
Description copied from interface:IRubyObjectConvert the object to the specified Java class, if possible.- Specified by:
toJavain interfaceIRubyObject- Overrides:
toJavain classRubyDate- Parameters:
target- The target type to which the object should be converted.- See Also:
-