Class: Hotwire::Response::Json::DateTime
- Inherits:
-
Object
- Object
- Hotwire::Response::Json::DateTime
- Defined in:
- lib/hotwire/response/json.rb
Overview
Utility class to produce a JSON rendering of datetimes compatible with what the Wire APIs expect ( a Javascript date object )
Instance Method Summary collapse
-
#initialize(datetime) ⇒ DateTime
constructor
A new instance of DateTime.
- #to_json(options = nil) ⇒ Object
Constructor Details
#initialize(datetime) ⇒ DateTime
Returns a new instance of DateTime.
84 85 86 |
# File 'lib/hotwire/response/json.rb', line 84 def initialize(datetime) @datetime = datetime end |
Instance Method Details
#to_json(options = nil) ⇒ Object
88 89 90 |
# File 'lib/hotwire/response/json.rb', line 88 def to_json(=nil) @datetime.nil? ? "" : "new Date(#{@datetime.year}, #{@datetime.month-1}, #{@datetime.day}, #{@datetime.hour}, #{@datetime.min}, #{@datetime.sec})" end |