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.
If time contains subsecond, they are truncated.
t = Time.now #=> 2020-07-21 01:41:29.746012609 +0900 t.to_i #=> 1595263289
Returns the number of microseconds for the subsecond part of time. The result is a non-negative integer less than 10**6.
t = Time.now #=> 2020-07-20 22:05:58.459785953 +0900 t.usec #=> 459785
If time has fraction of microsecond (such as nanoseconds), it is truncated.
t = Time.new(2000,1,1,0,0,0.666_777_888_999r) t.usec #=> 666777
Time#subsec
can be used to obtain the subsecond part exactly.
Returns the number of nanoseconds for the subsecond part of time. The result is a non-negative integer less than 10**9.
t = Time.now #=> 2020-07-20 22:07:10.963933942 +0900 t.nsec #=> 963933942
If time has fraction of nanosecond (such as picoseconds), it is truncated.
t = Time.new(2000,1,1,0,0,0.666_777_888_999r) t.nsec #=> 666777888
Time#subsec
can be used to obtain the subsecond part exactly.
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.