Module: Humanoid::Extensions::Time::Conversions

Included in:
Time
Defined in:
lib/humanoid/extensions/time/conversions.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#get(value) ⇒ Object



11
12
13
14
# File 'lib/humanoid/extensions/time/conversions.rb', line 11

def get(value)
  return nil if value.blank?
  ::Time.zone ? value.getlocal : value
end

#set(value) ⇒ Object



6
7
8
9
10
# File 'lib/humanoid/extensions/time/conversions.rb', line 6

def set(value)
  return nil if value.blank?
  time = ::Time.parse(value.is_a?(::Time) ? value.strftime("%Y-%m-%d %H:%M:%S %Z") : value.to_s)
  time.utc? ? time : time.utc
end