Sha256: 89943c18aded2f6c9a3a2234e1e0f386c536a0565932a51f9532be9f71ec2ae3

Contents?: true

Size: 469 Bytes

Versions: 11

Compression:

Stored size: 469 Bytes

Contents

class Time
  def to_json(*a)
    %("#{to_s(:json)}")
  end
  
  def to_s_with_json(*args)
    if args[0] == :json
      getutc.strftime("%Y/%m/%d %H:%M:%S +0000")
    else
      to_s_without_json *args
    end
  end
  alias_method :to_s_without_json, :to_s
  alias_method :to_s, :to_s_with_json
  
  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)
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
couch_potato-0.3.2 lib/core_ext/time.rb
couch_potato-0.3.1 lib/core_ext/time.rb
davber_couch_potato-0.3.0 lib/core_ext/time.rb
couch_potato-0.3.0 lib/core_ext/time.rb
couch_potato-0.2.32 lib/core_ext/time.rb
couch_potato-0.2.31 lib/core_ext/time.rb
couch_potato-0.2.30 lib/core_ext/time.rb
couch_potato-0.2.29 lib/core_ext/time.rb
couch_potato-0.2.28 lib/core_ext/time.rb
couch_potato-0.2.27 lib/core_ext/time.rb
couch_potato-0.2.26 lib/core_ext/time.rb