Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby: where has parsedate gone in 1.9?

I believe that older versions of ruby came with a parsedate module that allowed best-guess passing of date/time strings. This doesn't seem to be in ruby 1.9 -- is there an equivalent piece of functionality elsewhere?

like image 784
kdt Avatar asked Jan 18 '11 13:01

kdt


2 Answers

Had the same problem myself. Looking at the 1.8 source parsetime uses another module which is still around. The following works for me using Ruby 1.9 built from ports on FreeBSD.

require 'date/format'
require 'time'

text = "Tue Jun 28 11:58 2011"
array = Date._parse(text, false).values_at(:year, :mon, :mday, :hour, :min, :sec, :zone, :wday)
time = Time.mktime(*array)
puts time
like image 103
Jose Marques Avatar answered Nov 16 '22 00:11

Jose Marques


Date.parse

?

http://www.ensta.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/date/rdoc/index.html

like image 31
Satya Avatar answered Nov 16 '22 00:11

Satya