Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/core_ext/time.rb
Class Method Summary collapse
Instance Method Summary collapse
- #to_json(*a) ⇒ Object
- #to_s_with_json(*args) ⇒ Object (also: #to_s)
Class Method Details
.json_create(string) ⇒ Object
16 17 18 19 20 |
# File 'lib/core_ext/time.rb', line 16 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
#to_json(*a) ⇒ Object
2 3 4 |
# File 'lib/core_ext/time.rb', line 2 def to_json(*a) %("#{to_s(:json)}") end |
#to_s_with_json(*args) ⇒ Object Also known as: to_s
6 7 8 9 10 11 12 |
# File 'lib/core_ext/time.rb', line 6 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 |