class SoapyCake::TimeConverter
Attributes
zone[R]
Public Class Methods
new(time_zone)
click to toggle source
# File lib/soapy_cake/time_converter.rb, line 5 def initialize(time_zone) @zone = ActiveSupport::TimeZone[time_zone] end
Public Instance Methods
from_cake(value)
click to toggle source
# File lib/soapy_cake/time_converter.rb, line 14 def from_cake(value) zone.parse(value).utc end
to_cake(date)
click to toggle source
# File lib/soapy_cake/time_converter.rb, line 9 def to_cake(date) date = date.to_datetime if date.is_a?(Date) date.in_time_zone(zone).strftime('%Y-%m-%dT%H:%M:%S') end