Sha256: 011f11c62feb09c358d4faf897e9f37a8bfdb60736e90d3d9ff87ab27739bfdb

Contents?: true

Size: 439 Bytes

Versions: 1

Compression:

Stored size: 439 Bytes

Contents

require 'active_support/time'

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).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

1 entries across 1 versions & 1 rubygems

Version Path
couch_potato-0.5.0 lib/core_ext/time.rb