kdt
kdt

Reputation: 28499

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?

Upvotes: 10

Views: 5770

Answers (2)

Jose Marques
Jose Marques

Reputation: 91

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

Upvotes: 9

Related Questions