Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/core_ext/time.rb
Constant Summary collapse
- ToHKeys =
%i{sec min hour day month year wday yday isdst zone}.freeze
Instance Method Summary collapse
Instance Method Details
#at(args = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/core_ext/time.rb', line 3 def at(args = {}) norm = to_h.merge(args) utc_offset = args[:utc_offset] || strftime('%:z') ary = [ norm[:year], norm[:month], norm[:day], norm[:hour], norm[:min], norm[:sec], utc_offset ] self.class.new(*ary) end |
#to_h ⇒ Object
14 15 16 |
# File 'lib/core_ext/time.rb', line 14 def to_h Hash[ToHKeys.zip self.to_a] end |