Class: Date
Instance Method Summary collapse
-
#to_js(options = nil) ⇒ Object
Returns a Javascript string to create a Date object of the same date.
Instance Method Details
#to_js(options = nil) ⇒ Object
Returns a Javascript string to create a Date object of the same date.
Example:
Date.new(2005,2,1).to_js
# => "new Date(2005/02/01)"
7 8 9 |
# File 'lib/to-javascript/encoders/date.rb', line 7 def to_js( = nil) ActiveSupport::JS::Code.new "new Date('#{strftime("%Y/%m/%d")}')" end |