make Time.parse available
This commit is contained in:
parent
4581a10fb8
commit
a8eae5423d
|
@ -12,8 +12,18 @@ require File.dirname(__FILE__) + '/streamer'
|
|||
|
||||
# this date format sorts lexicographically
|
||||
# and is compatible with Javascript's new Date(time_string) constructor
|
||||
# note that sorting will break if you store times from multiple timezones
|
||||
# I like to add a ENV['TZ'] = 'UTC' to my apps
|
||||
class Time
|
||||
def to_json(options = nil)
|
||||
%("#{strftime("%Y/%m/%d %H:%M:%S %z")}")
|
||||
end
|
||||
# this works to decode the outputted time format
|
||||
# from ActiveSupport
|
||||
# def self.parse string, fallback=nil
|
||||
# d = DateTime.parse(string).new_offset
|
||||
# self.utc(d.year, d.month, d.day, d.hour, d.min, d.sec)
|
||||
# rescue
|
||||
# fallback
|
||||
# end
|
||||
end
|
Loading…
Reference in a new issue