Module: Transit::DateTimeUtil Private
- Defined in:
- lib/transit/date_time_util.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .from_millis(millis) ⇒ Object private
- .to_millis(v) ⇒ Object private
Class Method Details
.from_millis(millis) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 |
# File 'lib/transit/date_time_util.rb', line 32 def from_millis(millis) t = Time.at(millis / 1000).utc DateTime.new(t.year, t.month, t.day, t.hour, t.min, t.sec + (millis % 1000 * 0.001)) end |
.to_millis(v) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/transit/date_time_util.rb', line 18 def to_millis(v) case v when DateTime t = v.new_offset(0).to_time when Date t = Time.gm(v.year, v.month, v.day) when Time t = v else raise "Don't know how to get millis from #{t.inspect}" end (t.to_i * 1000) + (t.usec / 1000.0).round end |