org.jruby
Class RubyTime

java.lang.Object
  extended by org.jruby.RubyBasicObject
      extended by org.jruby.RubyObject
          extended by org.jruby.RubyTime
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<IRubyObject>, InstanceVariables, InternalVariables, IRubyObject, CoreObjectType

public class RubyTime
extends RubyObject

The Time class.

Author:
chadfowler, jpetersen
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Data, RubyObject.ObjectMethods
 
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.BasicObjectMethods, RubyBasicObject.Finalizer
 
Field Summary
static java.lang.String UTC
           
 
Fields inherited from class org.jruby.RubyObject
OBJECT_ALLOCATOR
 
Fields inherited from class org.jruby.RubyBasicObject
ALL_F, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F
 
Fields inherited from interface org.jruby.runtime.builtin.IRubyObject
NULL_ARRAY
 
Constructor Summary
RubyTime(Ruby runtime, RubyClass rubyClass)
           
RubyTime(Ruby runtime, RubyClass rubyClass, org.joda.time.DateTime dt)
           
 
Method Summary
 RubyString asctime()
           
static IRubyObject at(ThreadContext context, IRubyObject recv, IRubyObject arg)
           
static IRubyObject at(ThreadContext context, IRubyObject recv, IRubyObject arg1, IRubyObject arg2)
           
static RubyClass createTimeClass(Ruby runtime)
           
 RubyString dump(IRubyObject[] args, Block unusedBlock)
           
 IRubyObject eql_p(IRubyObject other)
          rb_obj_equal Just like "==" and "equal?", "eql?" will use identity equality for Object.
 org.joda.time.DateTime getDateTime()
           
 RubyTime getgm()
           
 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()
           
static org.joda.time.DateTimeZone getLocalTimeZone(Ruby runtime)
           
protected  long getTimeInMillis()
           
static org.joda.time.DateTimeZone getTimeZone(Ruby runtime, java.lang.String zone)
           
 long getUSec()
           
 RubyInteger gmt_offset()
           
 RubyBoolean gmt()
           
 RubyTime gmtime()
           
 RubyFixnum hash()
          rb_obj_id Will return the hash code of this object.
 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(Block block)
           
 RubyBoolean isdst()
           
static RubyTime load(IRubyObject recv, IRubyObject from, Block block)
           
 RubyTime localtime()
           
 RubyInteger mday()
           
 RubyObject mdump(IRubyObject[] args)
           
 long microseconds()
           
 RubyInteger min()
           
 RubyInteger month()
           
static RubyTime new_local(IRubyObject recv, IRubyObject[] args)
           
static RubyTime new_utc(IRubyObject recv, IRubyObject[] args)
           
static IRubyObject newInstance(ThreadContext context, IRubyObject recv)
           
static IRubyObject newInstance(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
          Deprecated. Use newInstance(ThreadContext, IRubyObject)
static RubyTime newTime(Ruby runtime, org.joda.time.DateTime dt)
           
static RubyTime newTime(Ruby runtime, org.joda.time.DateTime dt, long usec)
           
static RubyTime newTime(Ruby runtime, long milliseconds)
           
 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_plus(IRubyObject other)
           
protected static RubyTime s_mload(IRubyObject recv, RubyTime time, IRubyObject from)
           
static IRubyObject s_new(IRubyObject recv, IRubyObject[] args, Block block)
           
 RubyInteger sec()
           
 void setDateTime(org.joda.time.DateTime dt)
           
 void setMicroseconds(long mic)
           
 void setUSec(long usec)
           
 RubyString strftime(IRubyObject format)
           
 RubyTime succ()
           
static IRubyObject times(ThreadContext context, IRubyObject recv)
           
 RubyArray to_a()
          rb_any_to_a call-seq: obj.to_a -> anArray Returns an array representation of obj.
 RubyFloat to_f()
           
 RubyInteger to_i()
           
 IRubyObject to_s()
          rb_any_to_s call-seq: obj.to_s => string Returns a string representing obj.
 java.lang.Object toJava(java.lang.Class target)
          Convert the object to the specified Java class, if possible.
 void updateCal(org.joda.time.DateTime dt)
           
 RubyInteger usec()
           
 RubyInteger wday()
           
 RubyInteger yday()
           
 RubyInteger year()
           
 RubyString zone()
           
 
Methods inherited from class org.jruby.RubyObject
as, attachToObjectSpace, callInit, checkFrozen, convertToType, createObjectClass, display, dup, eqlInternal, equal_p, equalInternal, equals, evalUnder, evalUnder, extend, freeze, frozen_p, getNativeTypeIndex, hashCode, id_deprecated, id, initialize, inspect, 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, kind_of_p, method, methods, methods, methods19, nil_p, op_match, op_not_match, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, puts, rbClone, remove_instance_variable, respond_to_p, respond_to_p, send, send, send, send, send, singleton_methods, singleton_methods19, singletonMethods, specificEval, specificEval, specificEval, specificEval, specificEval, taint, tainted_p, to_java, toString, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable
 
Methods inherited from class org.jruby.RubyBasicObject
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkStringType, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, ensureInstanceVariablesSettable, eql, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, getFlag, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getMetaClass, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hasInstanceVariable, hasInternalVariable, hasVariables, infectBy, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isTaint, isTrue, isUntrusted, makeMetaClass, op_not_equal, op_not, removeFinalizers, removeInstanceVariable, removeInternalVariable, respondsTo, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, setUntrusted, setVariable, syncVariables, taint, testFrozen, testFrozen, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableGetSize, variableTableRemove, variableTableStore, variableTableSync
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

UTC

public static final java.lang.String UTC
See Also:
Constant Field Values
Constructor Detail

RubyTime

public RubyTime(Ruby runtime,
                RubyClass rubyClass)

RubyTime

public RubyTime(Ruby runtime,
                RubyClass rubyClass,
                org.joda.time.DateTime dt)
Method Detail

getLocalTimeZone

public static org.joda.time.DateTimeZone getLocalTimeZone(Ruby runtime)

getTimeZone

public static org.joda.time.DateTimeZone getTimeZone(Ruby runtime,
                                                     java.lang.String zone)

createTimeClass

public static RubyClass createTimeClass(Ruby runtime)

setUSec

public void setUSec(long usec)

getUSec

public long getUSec()

updateCal

public void updateCal(org.joda.time.DateTime dt)

getTimeInMillis

protected long getTimeInMillis()

newTime

public static RubyTime newTime(Ruby runtime,
                               long milliseconds)

newTime

public static RubyTime newTime(Ruby runtime,
                               org.joda.time.DateTime dt)

newTime

public static RubyTime newTime(Ruby runtime,
                               org.joda.time.DateTime dt,
                               long usec)

getJavaClass

public java.lang.Class<?> 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 interface IRubyObject
Overrides:
getJavaClass in class RubyBasicObject
Returns:
Class

initialize_copy

public IRubyObject initialize_copy(IRubyObject original)
Description copied from class: RubyObject
rb_obj_init_copy 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 class RubyObject

succ

public RubyTime succ()

gmtime

public RubyTime gmtime()

localtime

public RubyTime localtime()

gmt

public RubyBoolean gmt()

getgm

public RubyTime getgm()

getlocal

public RubyTime getlocal()

strftime

public RubyString strftime(IRubyObject format)

op_equal

public IRubyObject op_equal(ThreadContext context,
                            IRubyObject other)
Description copied from class: RubyObject
rb_obj_equal Will by default use identity equality to compare objects. This follows the Ruby semantics.

Specified by:
op_equal in interface IRubyObject
Overrides:
op_equal in class RubyObject

op_ge

public IRubyObject op_ge(ThreadContext context,
                         IRubyObject other)

op_gt

public IRubyObject op_gt(ThreadContext context,
                         IRubyObject other)

op_le

public IRubyObject op_le(ThreadContext context,
                         IRubyObject other)

op_lt

public IRubyObject op_lt(ThreadContext context,
                         IRubyObject other)

op_plus

public IRubyObject op_plus(IRubyObject other)

op_minus

public IRubyObject op_minus(IRubyObject other)

op_eqq

public IRubyObject op_eqq(ThreadContext context,
                          IRubyObject other)
Description copied from class: RubyObject
rb_equal The Ruby "===" method is used by default in case/when statements. The Object implementation first checks Java identity equality and then calls the "==" method too.

Specified by:
op_eqq in interface IRubyObject
Overrides:
op_eqq in class RubyObject

op_cmp

public IRubyObject op_cmp(ThreadContext context,
                          IRubyObject other)

eql_p

public IRubyObject eql_p(IRubyObject other)
Description copied from class: RubyObject
rb_obj_equal Just like "==" and "equal?", "eql?" will use identity equality for Object.

Overrides:
eql_p in class RubyObject

asctime

public RubyString asctime()

to_s

public IRubyObject to_s()
Description copied from class: RubyObject
rb_any_to_s call-seq: obj.to_s => string Returns a string representing obj. The default 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.''

Overrides:
to_s in class RubyObject

to_a

public RubyArray to_a()
Description copied from class: RubyObject
rb_any_to_a call-seq: obj.to_a -> anArray Returns an array representation of obj. For objects of class 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.

Overrides:
to_a in class RubyObject

to_f

public RubyFloat to_f()

to_i

public RubyInteger to_i()

usec

public RubyInteger usec()

setMicroseconds

public void setMicroseconds(long mic)

microseconds

public long microseconds()

sec

public RubyInteger sec()

min

public RubyInteger min()

hour

public RubyInteger hour()

mday

public RubyInteger mday()

month

public RubyInteger month()

year

public RubyInteger year()

wday

public RubyInteger wday()

yday

public RubyInteger yday()

gmt_offset

public RubyInteger gmt_offset()

isdst

public RubyBoolean isdst()

zone

public RubyString zone()

setDateTime

public void setDateTime(org.joda.time.DateTime dt)

getDateTime

public org.joda.time.DateTime getDateTime()

getJavaDate

public java.util.Date getJavaDate()

hash

public RubyFixnum hash()
Description copied from class: RubyObject
rb_obj_id 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 class RubyObject

dump

public RubyString dump(IRubyObject[] args,
                       Block unusedBlock)

mdump

public RubyObject mdump(IRubyObject[] args)

initialize

public IRubyObject initialize(Block block)

s_new

public static IRubyObject s_new(IRubyObject recv,
                                IRubyObject[] args,
                                Block block)

newInstance

@Deprecated
public static IRubyObject newInstance(ThreadContext context,
                                                 IRubyObject recv,
                                                 IRubyObject[] args,
                                                 Block block)
Deprecated. Use newInstance(ThreadContext, IRubyObject)


times

public static IRubyObject times(ThreadContext context,
                                IRubyObject recv)

newInstance

public static IRubyObject newInstance(ThreadContext context,
                                      IRubyObject recv)

at

public static IRubyObject at(ThreadContext context,
                             IRubyObject recv,
                             IRubyObject arg)

at

public static IRubyObject at(ThreadContext context,
                             IRubyObject recv,
                             IRubyObject arg1,
                             IRubyObject arg2)

new_local

public static RubyTime new_local(IRubyObject recv,
                                 IRubyObject[] args)

new_utc

public static RubyTime new_utc(IRubyObject recv,
                               IRubyObject[] args)

load

public static RubyTime load(IRubyObject recv,
                            IRubyObject from,
                            Block block)

toJava

public java.lang.Object toJava(java.lang.Class target)
Description copied from interface: IRubyObject
Convert the object to the specified Java class, if possible.

Specified by:
toJava in interface IRubyObject
Overrides:
toJava in class RubyBasicObject
Parameters:
target - The target type to which the object should be converted.
See Also:
IRubyObject.toJava

s_mload

protected static RubyTime s_mload(IRubyObject recv,
                                  RubyTime time,
                                  IRubyObject from)


Copyright © 2002-2009 JRuby Team. All Rights Reserved.