Method: Time#<=>

Defined in:
lib/source/ruby.rb

#<=>(time) ⇒ Object

call-seq:

time <=> other   -> -1, 0, 1
time <=> numeric -> -1, 0, 1

Comparison – compares time with other or with numeric, which is the number of seconds (possibly fractional) since epoch.

t1 = Time.now       #=> Tue Sep 23 2008 22:10:22 GMT-0400 (EDT)
t2 = t1 + 2592000   #=> Thu Oct 23 2008 22:10:22 GMT-0400 (EDT)
t1 <=> t2           #=> -1
t2 <=> t1           #=> 1
t1 <=> t1           #=> 0


6399
6400
6401
6402
6403
6404
6405
# File 'lib/source/ruby.rb', line 6399

def <=>(time)
  `var v=this.__value__.valueOf(),ms=typeof(time)=='number'?time*1000:time.__value__.valueOf()`
  `if(v<ms){return -1;}`
  `if(v==ms){return 0;}`
  `if(v>ms){return 1;}`
  return nil
end