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