Class: Time
Overview
Time
Class Method Summary collapse
-
.at(seconds, milliseconds) ⇒ Object
call-seq: Time.at(a_time) -> time Time.at(seconds [, microseconds]) -> time.
-
.now ⇒ Object
call-seq: Time.new -> time Time.now -> time.
Instance Method Summary collapse
-
#+(numeric) ⇒ Object
call-seq: time + numeric -> time.
-
#-(time) ⇒ Object
call-seq: time - other -> float time - numeric -> time.
-
#<=>(time) ⇒ Object
call-seq: time <=> other -> -1, 0, 1 time <=> numeric -> -1, 0, 1.
-
#day ⇒ Object
call-seq: time.day -> integer time.mday -> integer.
-
#dst? ⇒ Boolean
FIX: Incomplete.
-
#eql?(time) ⇒ Boolean
call-seq: time.eql?(other) -> true or false.
-
#getgm ⇒ Object
FIX: Incomplete.
-
#getlocal ⇒ Object
FIX: Incomplete.
-
#getutc ⇒ Object
FIX: Incomplete.
-
#gmt? ⇒ Boolean
FIX: Incomplete.
-
#gmt_offset ⇒ Object
call-seq: time.gmt_offset -> integer time.gmtoff -> integer time.utc_offset -> integer.
-
#gmtime ⇒ Object
FIX: Incomplete.
-
#gmtoff ⇒ Object
call-seq: time.gmt_offset -> integer time.gmtoff -> integer time.utc_offset -> integer.
-
#hash ⇒ Object
:nodoc:.
-
#hour ⇒ Object
call-seq: time.hour -> integer.
-
#initialize ⇒ Time
constructor
call-seq: Time.new -> time Time.now -> time.
-
#inspect ⇒ Object
call-seq: time.inspect -> string time.to_s -> string.
-
#isdst ⇒ Object
FIX: Incomplete.
-
#localtime ⇒ Object
FIX: Incomplete.
-
#mday ⇒ Object
call-seq: time.day -> integer time.mday -> integer.
-
#min ⇒ Object
call-seq: time.min -> integer.
-
#mon ⇒ Object
call-seq: time.mon -> integer time.month -> integer.
-
#month ⇒ Object
call-seq: time.mon -> integer time.month -> integer.
-
#sec ⇒ Object
call-seq: time.sec -> integer.
-
#strftime ⇒ Object
FIX: Incomplete.
-
#succ ⇒ Object
call-seq: time.succ -> new_time.
-
#to_a ⇒ Object
call-seq: time.to_a -> array.
-
#to_f ⇒ Object
call-seq: time.to_f -> numeric.
-
#to_i ⇒ Object
call-seq: time.to_i -> integer.
-
#to_s ⇒ Object
call-seq: time.inspect -> string time.to_s -> string.
-
#tv_sec ⇒ Object
call-seq: time.to_i -> integer.
-
#tv_usec ⇒ Object
call-seq: time.tv_usec -> integer time.usec -> integer.
-
#usec ⇒ Object
call-seq: time.tv_usec -> integer time.usec -> integer.
-
#utc ⇒ Object
FIX: Incomplete.
-
#utc? ⇒ Boolean
FIX: Incomplete.
-
#utc_offset ⇒ Object
call-seq: time.gmt_offset -> integer time.gmtoff -> integer time.utc_offset -> integer.
-
#wday ⇒ Object
call-seq: time.wday -> integer.
-
#yday ⇒ Object
call-seq: time.yday -> integer.
-
#year ⇒ Object
call-seq: time.year -> integer.
-
#zone ⇒ Object
FIX: Incomplete.
Constructor Details
#initialize ⇒ Time
call-seq:
Time.new -> time
Time.now -> time
Returns a Time object initialized to the current system time. The object created will include fractional seconds to the thousandths place.
t1 = Time.new #=> Tue Sep 23 2008 22:10:22 GMT-0400 (EDT)
t2 = Time.new #=> Tue Sep 23 2008 22:10:22 GMT-0400 (EDT)
t1 == t2 #=> false
t1.to_f #=> 1222222222.989
t2.to_f #=> 1222222222.991
6270 6271 6272 |
# File 'lib/source/ruby.rb', line 6270 def initialize `this._value=new(Date)` end |
Class Method Details
.at(seconds, milliseconds) ⇒ Object
call-seq:
Time.at(a_time) -> time
Time.at(seconds [, microseconds]) -> time
Creates a new time object with the value given by a_time, or the given number of seconds (and optional milliseconds) from epoch. A non-portable feature allows the offset to be negative on some systems.
Time.at(0) #=> Wed Dec 31 1969 19:00:00 GMT-0500 (EST)
Time.at(946702800) #=> Sat Jan 01 2000 00:00:00 GMT-0500 (EST)
Time.at(-284061600) #=> Sat Dec 31 1960 01:00:00 GMT-0500 (EST)
6234 6235 6236 6237 6238 |
# File 'lib/source/ruby.rb', line 6234 def self.at(seconds,milliseconds) `var t=c$Time.m$new()` `t._value=typeof(seconds)=='number'?new(Date)(seconds*1000+(milliseconds||0)):seconds._value` return `t` end |
.now ⇒ Object
call-seq:
Time.new -> time
Time.now -> time
Returns a Time object initialized to the current system time. The object created will include fractional seconds to the thousandths place.
t1 = Time.now #=> Tue Sep 23 2008 22:10:22 GMT-0400 (EDT)
t2 = Time.now #=> Tue Sep 23 2008 22:10:22 GMT-0400 (EDT)
t1 == t2 #=> false
t1.to_f #=> 1222222222.989
t2.to_f #=> 1222222222.991
6253 6254 6255 |
# File 'lib/source/ruby.rb', line 6253 def self.now Time.new end |
Instance Method Details
#+(numeric) ⇒ Object
6283 6284 6285 6286 6287 |
# File 'lib/source/ruby.rb', line 6283 def +(numeric) `var t=c$Time.m$new()` `t._value=new(Date)(numeric*1000+this._value.valueOf())` return `t` end |
#-(time) ⇒ Object
call-seq:
time - other -> float
time - numeric -> time
Difference – returns a new time that represents the difference between two times, or subtracts the given number of seconds in numeric from time.
t = Time.now #=> Tue Sep 23 2008 22:10:22 GMT-0400 (EDT)
t2 = t + 2592000 #=> Thu Oct 23 2008 22:10:22 GMT-0400 (EDT)
t2 - t #=> 2592000.0
t2 - 2592000 #=> Tue Sep 23 2008 22:10:22 GMT-0400 (EDT)
6302 6303 6304 |
# File 'lib/source/ruby.rb', line 6302 def -(time) `typeof(time)=='number'?new(Date)(this._value.valueOf()-(time*1000)):(this._value.valueOf()-time._value.valueOf())/1000` end |
#<=>(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
6319 6320 6321 6322 6323 6324 6325 |
# File 'lib/source/ruby.rb', line 6319 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 |
#day ⇒ Object
6336 6337 6338 |
# File 'lib/source/ruby.rb', line 6336 def day `this._value.getDate()` end |
#dst? ⇒ Boolean
FIX: Incomplete
6341 6342 |
# File 'lib/source/ruby.rb', line 6341 def dst? end |
#eql?(time) ⇒ Boolean
call-seq:
time.eql?(other) -> true or false
Return true if time and other are both Time objects with the same seconds and fractional seconds.
6350 6351 6352 6353 |
# File 'lib/source/ruby.rb', line 6350 def eql?(time) `if(time.constructor!=c$Time){return false;}` `this._value.valueOf()==time._value.valueOf()` end |
#getlocal ⇒ Object
FIX: Incomplete
6360 6361 |
# File 'lib/source/ruby.rb', line 6360 def getlocal end |
#gmt? ⇒ Boolean
FIX: Incomplete
6368 6369 |
# File 'lib/source/ruby.rb', line 6368 def gmt? end |
#gmt_offset ⇒ Object
6381 6382 6383 |
# File 'lib/source/ruby.rb', line 6381 def gmt_offset `this._value.getTimezoneOffset() * -60` end |
#gmtoff ⇒ Object
6399 6400 6401 |
# File 'lib/source/ruby.rb', line 6399 def gmtoff `this._value.getTimezoneOffset() * -60` end |
#hash ⇒ Object
:nodoc:
6403 6404 6405 |
# File 'lib/source/ruby.rb', line 6403 def hash # :nodoc: `'t_'+this._value.valueOf()/1000` end |
#hour ⇒ Object
6415 6416 6417 |
# File 'lib/source/ruby.rb', line 6415 def hour `this._value.getHours()` end |
#inspect ⇒ Object
6427 6428 6429 |
# File 'lib/source/ruby.rb', line 6427 def inspect `$q(''+this)` end |
#localtime ⇒ Object
FIX: Incomplete
6436 6437 |
# File 'lib/source/ruby.rb', line 6436 def localtime end |
#mday ⇒ Object
6448 6449 6450 |
# File 'lib/source/ruby.rb', line 6448 def mday `this._value.getDate()` end |
#min ⇒ Object
6460 6461 6462 |
# File 'lib/source/ruby.rb', line 6460 def min `this._value.getMinutes()` end |
#mon ⇒ Object
6473 6474 6475 |
# File 'lib/source/ruby.rb', line 6473 def mon `this._value.getMonth()` end |
#month ⇒ Object
6486 6487 6488 |
# File 'lib/source/ruby.rb', line 6486 def month `this._value.getMonth()` end |
#sec ⇒ Object
6498 6499 6500 |
# File 'lib/source/ruby.rb', line 6498 def sec `this._value.getSeconds()` end |
#strftime ⇒ Object
FIX: Incomplete
6503 6504 |
# File 'lib/source/ruby.rb', line 6503 def strftime end |
#succ ⇒ Object
call-seq:
time.succ -> new_time
Returns a new time object, one second later than time.
6511 6512 6513 6514 6515 |
# File 'lib/source/ruby.rb', line 6511 def succ `var t=c$Time.m$new()` `t._value=new(Date)(1000+this._value.valueOf())` return `t` end |
#to_a ⇒ Object
call-seq:
time.to_a -> array
Returns a ten-element array of values for time: [ sec, min, hour, day, month, year, wday, yday, isdst, zone ]<tt/>. The ten elements can be passed directly to <tt>Time::utc or Time::local to create a new Time.
t = Time.now #=> Tue Sep 23 2008 22:10:22 GMT-0400 (EDT)
t.to_a #=> [22, 10, 22, 23, 9, 2008, 2, 267, true, "EDT"]
FIX: Incomplete
6529 6530 6531 |
# File 'lib/source/ruby.rb', line 6529 def to_a [] end |
#to_f ⇒ Object
6542 6543 6544 |
# File 'lib/source/ruby.rb', line 6542 def to_f `this._value.valueOf()/1000` end |
#to_i ⇒ Object
6554 6555 6556 |
# File 'lib/source/ruby.rb', line 6554 def to_i `parseInt(this._value.valueOf()/1000)` end |
#to_s ⇒ Object
6566 6567 6568 |
# File 'lib/source/ruby.rb', line 6566 def to_s `$q(''+this._value)` end |
#tv_sec ⇒ Object
6578 6579 6580 |
# File 'lib/source/ruby.rb', line 6578 def tv_sec `parseInt(this._value.valueOf()/1000)` end |
#tv_usec ⇒ Object
6592 6593 6594 |
# File 'lib/source/ruby.rb', line 6592 def tv_usec `parseInt(this._value.valueOf()/1000)` end |
#usec ⇒ Object
6606 6607 6608 6609 |
# File 'lib/source/ruby.rb', line 6606 def usec `var v = this._value.valueOf()` `(v*1000)-parseInt(v/1000)*1000000` end |
#utc? ⇒ Boolean
FIX: Incomplete
6616 6617 |
# File 'lib/source/ruby.rb', line 6616 def utc? end |
#utc_offset ⇒ Object
6629 6630 6631 |
# File 'lib/source/ruby.rb', line 6629 def utc_offset `this._value.getTimezoneOffset() * -60` end |
#wday ⇒ Object
6641 6642 6643 |
# File 'lib/source/ruby.rb', line 6641 def wday `this._value.getDay()` end |
#yday ⇒ Object
6653 6654 6655 6656 |
# File 'lib/source/ruby.rb', line 6653 def yday `var d2=new Date(),d1=new Date(new Date(new Date().setFullYear(d2.getFullYear(),0,0)).setHours(0,0,0,0))` `parseInt((d2-d1)/1000/60/60/24)` end |
#year ⇒ Object
6666 6667 6668 |
# File 'lib/source/ruby.rb', line 6666 def year `this._value.getFullYear()` end |