Sha256: 3f79f4e7623ba1113976aecf8a6841024401e886f7d52be99d21eb3f3683e345

Contents?: true

Size: 454 Bytes

Versions: 4

Compression:

Stored size: 454 Bytes

Contents

require 'active_support/time_with_zone'

class Time
  def to_json(*a)
    %("#{as_json}")
  end
  
  def as_json(*args)
    getutc.strftime("%Y/%m/%d %H:%M:%S +0000")
  end
  
  def self.json_create string
    return nil if string.nil?
    d = DateTime.parse(string.to_s).new_offset
    self.utc(d.year, d.month, d.day, d.hour, d.min, d.sec).in_time_zone
  end
end

ActiveSupport::TimeWithZone.class_eval do
  def as_json(*args)
    utc.as_json
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
couch_potato-rails2-0.5.10 lib/core_ext/time.rb
couch_potato-rails2-0.5.9 lib/core_ext/time.rb
couch_potato-rails2-0.5.8 lib/core_ext/time.rb
couch_potato-rails2-0.5.7 lib/core_ext/time.rb