Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tag: v2.0.0_RC1
Fetching contributors…

Cannot retrieve contributors at this time

23 lines (20 sloc) 0.625 kB
require 'parsedate'
module ActiveSupport #:nodoc:
module CoreExtensions #:nodoc:
module String #:nodoc:
# Converting strings to other objects
module Conversions
# Form can be either :utc (default) or :local.
def to_time(form = :utc)
::Time.send("#{form}_time", *ParseDate.parsedate(self)[0..5].map {|arg| arg || 0})
end
def to_date
::Date.new(*ParseDate.parsedate(self)[0..2])
end
def to_datetime
::DateTime.civil(*ParseDate.parsedate(self)[0..5].map {|arg| arg || 0} << 0 << 0)
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.