Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/time.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(string) ⇒ Object



10
11
12
13
14
# File 'lib/core_ext/time.rb', line 10

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

Instance Method Details

#as_json(*args) ⇒ Object



6
7
8
# File 'lib/core_ext/time.rb', line 6

def as_json(*args)
  getutc.strftime("%Y/%m/%d %H:%M:%S +0000")
end

#to_json(*a) ⇒ Object



2
3
4
# File 'lib/core_ext/time.rb', line 2

def to_json(*a)
  %("#{as_json}")
end