Module: MuchRails::Time
- Defined in:
- lib/much-rails/time.rb
Constant Summary collapse
- InvalidError =
Class.new(TypeError)
Class Method Summary collapse
Class Method Details
.for(value) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/much-rails/time.rb', line 17 def self.for(value) return if value.blank? if value.respond_to?(:to_time) && !value.is_a?(::String) value.to_time.utc else ::Time.iso8601(value.to_s).utc end rescue raise MuchRails::Time::InvalidError, "Invalid Time: #{value.inspect}." end |