Class: Time
- Inherits:
-
Object
- Object
- Time
- Defined in:
- lib/core_ext/time.rb
Overview
use ISO8601 as timeformat
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.json_create(string) ⇒ Object
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
#as_json(*args) ⇒ Object
8 9 10 |
# File 'lib/core_ext/time.rb', line 8 def as_json(*args) getutc.iso8601 end |
#to_json(*a) ⇒ Object
4 5 6 |
# File 'lib/core_ext/time.rb', line 4 def to_json(*a) %|"#{as_json}"| end |