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

+ (Object) json_create(string)



12
13
14
15
16
# File 'lib/core_ext/time.rb', line 12

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

Instance Method Details

- (Object) as_json(*args)



8
9
10
# File 'lib/core_ext/time.rb', line 8

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

- (Object) to_json(*a)



4
5
6
# File 'lib/core_ext/time.rb', line 4

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