Class: Date

Inherits:
Object show all
Defined in:
lib/to-javascript/encoders/date.rb

Instance Method Summary collapse

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(options = nil)
 ActiveSupport::JS::Code.new "new Date('#{strftime("%Y/%m/%d")}')"
end