public class RubyTime extends RubyObject
RubyObject.Data
RubyBasicObject.Finalizer
Modifier and Type | Field and Description |
---|---|
static int |
TIME_SCALE |
static java.lang.String |
UTC |
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
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, varTableStamp
NULL_ARRAY
Constructor and Description |
---|
RubyTime(Ruby runtime,
RubyClass rubyClass) |
RubyTime(Ruby runtime,
RubyClass rubyClass,
org.joda.time.DateTime dt) |
RubyTime(Ruby runtime,
RubyClass rubyClass,
org.joda.time.DateTime dt,
boolean tzRelative) |
Modifier and Type | Method and Description |
---|---|
RubyString |
asctime() |
static IRubyObject |
at(ThreadContext context,
IRubyObject recv,
IRubyObject arg) |
static IRubyObject |
at(ThreadContext context,
IRubyObject recv,
IRubyObject arg1,
IRubyObject arg2) |
static IRubyObject |
at(ThreadContext context,
IRubyObject recv,
IRubyObject arg1,
IRubyObject arg2,
IRubyObject arg3) |
static double |
convertTimeInterval(ThreadContext context,
IRubyObject sec) |
static RubyClass |
createTimeClass(Ruby runtime) |
RubyString |
dump(IRubyObject[] args,
Block unusedBlock)
Deprecated.
|
RubyString |
dump(ThreadContext context) |
RubyString |
dump(ThreadContext context,
IRubyObject arg) |
IRubyObject |
eql_p(IRubyObject other)
rb_obj_equal
Just like "==" and "equal?", "eql?" will use identity equality for Object.
|
RubyBoolean |
friday_p(ThreadContext context) |
org.joda.time.DateTime |
getDateTime() |
int |
getDay() |
static java.lang.String |
getEnvTimeZone(Ruby runtime) |
RubyTime |
getgm() |
int |
getHour() |
java.lang.Class<?> |
getJavaClass()
Will return the Java interface that most closely can represent
this object, when working through Java integration translations.
|
java.util.Date |
getJavaDate() |
RubyTime |
getlocal() |
RubyTime |
getlocal(ThreadContext context) |
RubyTime |
getlocal(ThreadContext context,
IRubyObject arg) |
RubyTime |
getlocal19(ThreadContext context,
IRubyObject[] args)
Deprecated.
|
static org.joda.time.DateTimeZone |
getLocalTimeZone(Ruby runtime) |
int |
getMicros()
Return the micro-seconds of this time.
|
int |
getMinute() |
int |
getMonth() |
int |
getNanos()
Return the nano-seconds of this time.
|
ClassIndex |
getNativeClassIndex()
This is overridden in the other concrete Java builtins to provide a fast way
to determine what type they are.
|
long |
getNSec()
Get the nano-second (only) part of the time.
|
static java.lang.String |
getRubyTimeZoneName(Ruby runtime,
org.joda.time.DateTime dt) |
static java.lang.String |
getRubyTimeZoneName(java.lang.String envTZ,
org.joda.time.DateTime dt) |
int |
getSecond() |
long |
getTimeInMicros() |
long |
getTimeInMillis() |
static org.joda.time.DateTimeZone |
getTimeZone(Ruby runtime,
long seconds) |
static org.joda.time.DateTimeZone |
getTimeZoneFromString(Ruby runtime,
java.lang.String zone) |
static org.joda.time.DateTimeZone |
getTimeZoneFromTZString(Ruby runtime,
java.lang.String zone) |
static org.joda.time.DateTimeZone |
getTimeZoneFromUtcOffset(ThreadContext context,
IRubyObject utcOffset) |
static org.joda.time.DateTimeZone |
getTimeZoneWithOffset(Ruby runtime,
java.lang.String zoneName,
int offset) |
long |
getUSec()
Get the micro-second (only) part of the time.
|
int |
getYear() |
java.lang.String |
getZoneName() |
RubyInteger |
gmt_offset() |
RubyBoolean |
gmt() |
RubyTime |
gmtime() |
RubyFixnum |
hash()
rb_obj_id
Will return the hash code of this object.
|
int |
hashCode()
This override does not do "checked" dispatch since Object usually has #hash defined.
|
RubyInteger |
hour() |
IRubyObject |
initialize_copy(IRubyObject original)
rb_obj_init_copy
Initializes this object as a copy of the original, that is the
parameter to this object.
|
IRubyObject |
initialize(ThreadContext context,
IRubyObject[] args) |
RubyBoolean |
isdst() |
boolean |
isUTC() |
static RubyTime |
load(IRubyObject recv,
IRubyObject from,
Block block)
Deprecated.
|
static RubyTime |
load(ThreadContext context,
IRubyObject recv,
IRubyObject from) |
static RubyTime |
local(ThreadContext context,
IRubyObject recv,
IRubyObject[] args) |
RubyTime |
localtime() |
RubyTime |
localtime(ThreadContext context) |
RubyTime |
localtime(ThreadContext context,
IRubyObject arg) |
RubyTime |
localtime19(ThreadContext context,
IRubyObject[] args)
Deprecated.
|
RubyInteger |
mday() |
RubyObject |
mdump()
Deprecated.
|
long |
microseconds()
Deprecated.
use
getMicros() instead |
RubyInteger |
min() |
RubyBoolean |
monday_p(ThreadContext context) |
RubyInteger |
month() |
static RubyTime |
new_local(IRubyObject recv,
IRubyObject[] args)
Deprecated.
|
static RubyTime |
new_utc(IRubyObject recv,
IRubyObject[] args)
Deprecated.
|
static IRubyObject |
new19(ThreadContext context,
IRubyObject recv,
IRubyObject[] args)
Deprecated.
|
static RubyTime |
newInstance(ThreadContext context,
IRubyObject recv) |
static IRubyObject |
newInstance(ThreadContext context,
IRubyObject recv,
IRubyObject[] args,
Block block)
Deprecated.
|
static RubyTime |
newTime(Ruby runtime,
org.joda.time.DateTime dt) |
static RubyTime |
newTime(Ruby runtime,
org.joda.time.DateTime dt,
long nsec)
Create new (Ruby) Time instance.
|
static RubyTime |
newTime(Ruby runtime,
long milliseconds) |
static RubyTime |
newTimeFromNanoseconds(Ruby runtime,
long nanoseconds) |
RubyInteger |
nsec()
Get the fractional part of time in nanoseconds.
|
IRubyObject |
op_cmp(ThreadContext context,
IRubyObject other) |
IRubyObject |
op_eqq(ThreadContext context,
IRubyObject other)
rb_equal
The Ruby "===" method is used by default in case/when
statements.
|
IRubyObject |
op_equal(ThreadContext context,
IRubyObject other)
rb_obj_equal
Will by default use identity equality to compare objects.
|
IRubyObject |
op_ge(ThreadContext context,
IRubyObject other) |
IRubyObject |
op_gt(ThreadContext context,
IRubyObject other) |
IRubyObject |
op_le(ThreadContext context,
IRubyObject other) |
IRubyObject |
op_lt(ThreadContext context,
IRubyObject other) |
IRubyObject |
op_minus(IRubyObject other) |
IRubyObject |
op_minus(ThreadContext context,
IRubyObject other) |
IRubyObject |
op_minus19(ThreadContext context,
IRubyObject other)
Deprecated.
|
IRubyObject |
op_plus(IRubyObject other) |
IRubyObject |
op_plus(ThreadContext context,
IRubyObject other) |
IRubyObject |
op_plus19(ThreadContext context,
IRubyObject other)
Deprecated.
|
RubyTime |
round(ThreadContext context,
IRubyObject[] args) |
static IRubyObject |
s_new(IRubyObject recv,
IRubyObject[] args,
Block block)
Deprecated.
|
RubyBoolean |
saturday_p(ThreadContext context) |
RubyInteger |
sec() |
void |
setDateTime(org.joda.time.DateTime dt) |
void |
setMicros(int micros)
Sets the microsecond part for this Time object.
|
void |
setMicroseconds(long micros)
Deprecated.
use
setMicros(int) instead |
void |
setNanos(int nanos)
Sets the nanosecond part for this Time object.
|
void |
setNSec(long nsec)
Set the nano-second (only) part for this time.
|
void |
setUSec(long usec)
Set the micro-second (only) part of the time.
|
RubyString |
strftime(IRubyObject format)
Deprecated.
|
RubyString |
strftime(ThreadContext context,
IRubyObject format) |
IRubyObject |
subsec()
Deprecated.
|
RubyNumeric |
subsec(ThreadContext context) |
RubyTime |
succ() |
RubyBoolean |
sunday_p(ThreadContext context) |
RubyBoolean |
thursday_p(ThreadContext context) |
RubyArray |
to_a(ThreadContext context)
rb_any_to_a
call-seq:
obj.to_a -> anArray
Returns an array representation of obj.
|
RubyFloat |
to_f() |
RubyInteger |
to_i() |
IRubyObject |
to_r(ThreadContext context) |
IRubyObject |
to_s()
rb_any_to_s
call-seq:
obj.to_s => string
Returns a string representing obj.
|
IRubyObject |
to_s19() |
java.time.Instant |
toInstant() |
<T> T |
toJava(java.lang.Class<T> target)
Convert the object to the specified Java class, if possible.
|
java.time.LocalDateTime |
toLocalDateTime() |
java.time.OffsetDateTime |
toOffsetDateTime() |
java.lang.String |
toString()
The default toString method is just a wrapper that calls the
Ruby "to_s" method.
|
java.time.ZonedDateTime |
toZonedDateTime() |
RubyBoolean |
tuesday_p(ThreadContext context) |
void |
updateCal(org.joda.time.DateTime dt)
Deprecated.
|
RubyInteger |
usec()
Get the microsecond part of this time value.
|
static RubyTime |
utc(ThreadContext context,
IRubyObject recv,
IRubyObject[] args) |
RubyInteger |
wday() |
RubyBoolean |
wednesday_p(ThreadContext context) |
RubyInteger |
yday() |
RubyInteger |
year() |
IRubyObject |
zone() |
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, dig, eqlInternal, equalInternal, equals, inspect, puts, specificEval, toRubyString
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, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize19, inspect, 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_missing, method_missing19, method, method19, methods, methods, methods19, nil_p, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_equal_19, op_match, op_match19, op_not_equal, op_not_match, op_not, 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_added, singleton_method_added19, singleton_method_removed, singleton_method_removed19, singleton_method_undefined, singleton_method_undefined19, singleton_method, singleton_methods, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
array
public static final java.lang.String UTC
public static final int TIME_SCALE
public ClassIndex getNativeClassIndex()
RubyObject
getNativeClassIndex
in interface CoreObjectType
getNativeClassIndex
in class RubyObject
ClassIndex
public static java.lang.String getEnvTimeZone(Ruby runtime)
public static org.joda.time.DateTimeZone getLocalTimeZone(Ruby runtime)
public static org.joda.time.DateTimeZone getTimeZoneFromTZString(Ruby runtime, java.lang.String zone)
public static org.joda.time.DateTimeZone getTimeZoneFromString(Ruby runtime, java.lang.String zone)
public static org.joda.time.DateTimeZone getTimeZoneFromUtcOffset(ThreadContext context, IRubyObject utcOffset)
public static org.joda.time.DateTimeZone getTimeZone(Ruby runtime, long seconds)
public static org.joda.time.DateTimeZone getTimeZoneWithOffset(Ruby runtime, java.lang.String zoneName, int offset)
public void setNSec(long nsec)
nsec
means the 4 to 9 decimal places of sec fractional part of time.
For example, 123456 for nsec
means .000123456
, not .123456000
.nsec
- the nano second part only (4 to 9 decimal places) of timepublic long getNSec()
1500000000.123456789
returns 456789
.public void setUSec(long usec)
usec
- setNSec(long)
public long getUSec()
getUSec()
@Deprecated public void updateCal(org.joda.time.DateTime dt)
setDateTime(DateTime)
instead.public static RubyTime newTimeFromNanoseconds(Ruby runtime, long nanoseconds)
public static RubyTime newTime(Ruby runtime, org.joda.time.DateTime dt, long nsec)
dt
of org.joda.time.DateTime
represents the integer part and
the fraction part to milliseconds, and nsec
the nano part (4 to 9 decimal places).
For example, RubyTime.newTime(rt, new DateTime(987000), 345678)
creates an epoch
second of 987.000345678
, not 987000.345678
.runtime
- the runtimedt
- the integer part of time + the fraction part in millisecondsnsec
- the nanos only party of the time (millis excluded)setNSec(long)
public IRubyObject initialize_copy(IRubyObject original)
RubyBasicObject
initialize_copy
in class RubyBasicObject
public RubyTime succ()
public RubyTime gmtime()
public final RubyTime localtime()
public RubyTime localtime(ThreadContext context)
public RubyTime localtime(ThreadContext context, IRubyObject arg)
@Deprecated public final RubyTime localtime19(ThreadContext context, IRubyObject[] args)
public RubyBoolean gmt()
public boolean isUTC()
public RubyTime getgm()
public final RubyTime getlocal()
public RubyTime getlocal(ThreadContext context)
public RubyTime getlocal(ThreadContext context, IRubyObject arg)
@Deprecated public RubyTime getlocal19(ThreadContext context, IRubyObject[] args)
@Deprecated public RubyString strftime(IRubyObject format)
public RubyString strftime(ThreadContext context, IRubyObject format)
public IRubyObject op_equal(ThreadContext context, IRubyObject other)
RubyBasicObject
op_equal
in interface IRubyObject
op_equal
in class RubyBasicObject
public IRubyObject op_ge(ThreadContext context, IRubyObject other)
public IRubyObject op_gt(ThreadContext context, IRubyObject other)
public IRubyObject op_le(ThreadContext context, IRubyObject other)
public IRubyObject op_lt(ThreadContext context, IRubyObject other)
public IRubyObject op_plus(IRubyObject other)
public IRubyObject op_plus(ThreadContext context, IRubyObject other)
@Deprecated public IRubyObject op_plus19(ThreadContext context, IRubyObject other)
public IRubyObject op_minus(IRubyObject other)
public IRubyObject op_minus(ThreadContext context, IRubyObject other)
@Deprecated public IRubyObject op_minus19(ThreadContext context, IRubyObject other)
public IRubyObject op_eqq(ThreadContext context, IRubyObject other)
RubyObject
op_eqq
in interface IRubyObject
op_eqq
in class RubyObject
public IRubyObject op_cmp(ThreadContext context, IRubyObject other)
op_cmp
in class RubyBasicObject
public IRubyObject eql_p(IRubyObject other)
RubyBasicObject
eql_p
in class RubyBasicObject
public RubyString asctime()
public IRubyObject to_s()
RubyBasicObject
to_s
prints the object's class and an encoding of the
object id. As a special case, the top-level object that is the
initial execution context of Ruby programs returns ``main.''to_s
in class RubyBasicObject
public final IRubyObject to_s19()
public java.lang.String toString()
RubyObject
toString
in class RubyObject
public RubyArray to_a(ThreadContext context)
RubyBasicObject
Object
and others that don't explicitly override the
method, the return value is an array containing self
.
However, this latter behavior will soon be obsolete.
self.to_a #=> -:1: warning: default `to_a' will be obsolete
"hello".to_a #=> ["hello"]
Time.new.to_a #=> [39, 54, 8, 9, 4, 2003, 3, 99, true, "CDT"]
The default to_a method is deprecated.to_a
in class RubyBasicObject
public RubyFloat to_f()
public RubyInteger to_i()
public RubyInteger nsec()
RubyTime#getNSec
. This method represents Ruby's nsec
method.public IRubyObject to_r(ThreadContext context)
public RubyInteger usec()
public long getTimeInMicros()
getTimeInMillis()
public int getMicros()
getTimeInMicros()
public void setMicros(int micros)
micros
- the microseconds to be setgetMicros()
public void setMicroseconds(long micros)
setMicros(int)
insteadpublic long microseconds()
getMicros()
insteadpublic int getNanos()
public void setNanos(int nanos)
nanos
- the nanoseconds to be setgetNanos()
public RubyInteger sec()
public RubyInteger min()
public RubyInteger hour()
public RubyInteger mday()
public RubyInteger month()
public RubyInteger year()
public RubyInteger wday()
public RubyInteger yday()
public RubyBoolean sunday_p(ThreadContext context)
public RubyBoolean monday_p(ThreadContext context)
public RubyBoolean tuesday_p(ThreadContext context)
public RubyBoolean wednesday_p(ThreadContext context)
public RubyBoolean thursday_p(ThreadContext context)
public RubyBoolean friday_p(ThreadContext context)
public RubyBoolean saturday_p(ThreadContext context)
@Deprecated public IRubyObject subsec()
public RubyNumeric subsec(ThreadContext context)
public RubyInteger gmt_offset()
public RubyBoolean isdst()
public IRubyObject zone()
public java.lang.String getZoneName()
public static java.lang.String getRubyTimeZoneName(Ruby runtime, org.joda.time.DateTime dt)
public static java.lang.String getRubyTimeZoneName(java.lang.String envTZ, org.joda.time.DateTime dt)
public void setDateTime(org.joda.time.DateTime dt)
public org.joda.time.DateTime getDateTime()
public RubyFixnum hash()
RubyBasicObject
hash
in class RubyBasicObject
public int hashCode()
RubyObject
hashCode
in class RubyObject
RubyBasicObject.hashCode()
public RubyString dump(ThreadContext context)
public RubyString dump(ThreadContext context, IRubyObject arg)
@Deprecated public RubyString dump(IRubyObject[] args, Block unusedBlock)
@Deprecated public RubyObject mdump()
public RubyTime round(ThreadContext context, IRubyObject[] args)
@Deprecated public static IRubyObject s_new(IRubyObject recv, IRubyObject[] args, Block block)
newInstance(ThreadContext, IRubyObject)
@Deprecated public static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
newInstance(ThreadContext, IRubyObject)
public static RubyTime newInstance(ThreadContext context, IRubyObject recv)
public static IRubyObject at(ThreadContext context, IRubyObject recv, IRubyObject arg)
public static IRubyObject at(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2)
public static IRubyObject at(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3)
public static RubyTime local(ThreadContext context, IRubyObject recv, IRubyObject[] args)
public IRubyObject initialize(ThreadContext context, IRubyObject[] args)
public static RubyTime utc(ThreadContext context, IRubyObject recv, IRubyObject[] args)
@Deprecated public static RubyTime load(IRubyObject recv, IRubyObject from, Block block)
public static RubyTime load(ThreadContext context, IRubyObject recv, IRubyObject from)
public java.lang.Class<?> getJavaClass()
RubyBasicObject
getJavaClass
in interface IRubyObject
getJavaClass
in class RubyBasicObject
public <T> T toJava(java.lang.Class<T> target)
IRubyObject
toJava
in interface IRubyObject
toJava
in class RubyBasicObject
target
- The target type to which the object should be converted.IRubyObject.toJava(java.lang.Class<T>)
public long getTimeInMillis()
public int getYear()
public int getMonth()
public int getDay()
public int getHour()
public int getMinute()
public int getSecond()
public java.util.Date getJavaDate()
public java.time.Instant toInstant()
public java.time.LocalDateTime toLocalDateTime()
public java.time.ZonedDateTime toZonedDateTime()
public java.time.OffsetDateTime toOffsetDateTime()
public static double convertTimeInterval(ThreadContext context, IRubyObject sec)
@Deprecated public static RubyTime new_local(IRubyObject recv, IRubyObject[] args)
@Deprecated public static RubyTime new_utc(IRubyObject recv, IRubyObject[] args)
@Deprecated public static IRubyObject new19(ThreadContext context, IRubyObject recv, IRubyObject[] args)
Copyright © 2001-2021 JRuby. All Rights Reserved.