Returns a DateTime
object which denotes self.
Returns a hash, that will be turned into a JSON
object and represent this object.
Stores class name (Time
) with number of seconds since epoch and number of microseconds for Time
as JSON
string
Returns the offset in seconds between the timezone of time and UTC.
t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt_offset #=> 0 l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.gmt_offset #=> -21600
Returns the offset in seconds between the timezone of time and UTC.
t = Time.gm(2000,1,1,20,15,1) #=> 2000-01-01 20:15:01 UTC t.gmt_offset #=> 0 l = t.getlocal #=> 2000-01-01 14:15:01 -0600 l.gmt_offset #=> -21600
Returns the value of time as an integer number of seconds since the Epoch.
t = Time.now "%10.5f" % t.to_f #=> "1270968656.89607" t.to_i #=> 1270968656
Returns the number of microseconds for time.
t = Time.now #=> 2007-11-19 08:03:26 -0600 "%10.6f" % t.to_f #=> "1195481006.775195" t.usec #=> 775195
Returns the number of nanoseconds for time.
t = Time.now #=> 2007-11-17 15:18:03 +0900 "%10.9f" % t.to_f #=> "1195280283.536151409" t.nsec #=> 536151406
The lowest digits of to_f
and nsec
are different because IEEE 754 double is not accurate enough to represent the exact number of nanoseconds since the Epoch.
The more accurate value is returned by nsec
.
Calls the block once for each [key, value] pair in the database. Returns self.
Returns a hash, that will be turned into a JSON
object and represent this object.
Yields the name and value of each struct member in order. If no block is given an enumerator is returned.
Customer = Struct.new(:name, :address, :zip) joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345) joe.each_pair {|name, value| puts("#{name} => #{value}") }
Produces:
name => Joe Smith address => 123 Maple, Anytown NC zip => 12345
Returns a data represents the current console mode.
You must require ‘io/console’ to use this method.