[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

RFC-822 dates into Ruby dates

(Kelly Greer)

6/8/2008 10:13:00 PM

Whats the right way in Ruby to pull these kind of dates apart into a
Ruby Date?

Mon, 8 Aug 2005 16:25:00 GMT

I'm working on parsing several RSS feeds and storing the data in
MySQL.

Thanks,
Kelly Greer
kellygreer1@nospam.com
change nospam into yahoo


1 Answer

Eric I.

6/8/2008 11:00:00 PM

0

On Jun 8, 6:12 pm, kellygreer1 <kellygre...@yahoo.com> wrote:
> Whats the right way in Ruby to pull these kind of dates apart into a
> Ruby Date?
>
> Mon, 8 Aug 2005 16:25:00 GMT

Hi Kelly,

The DateTime class (in library 'date') can parse those strings.

====

require 'date'
d = DateTime.parse("Mon, 8 Aug 2005 16:25:00 GMT")
puts d.year
puts d.hour
puts d.zone
# and so forth... *or*
puts d.strftime "%Y %H %Z"

====

Hope that helps,

Eric

====

LearnRuby.com offers Rails & Ruby HANDS-ON public & ON-SITE
workshops.
Ruby Fundamentals Wkshp June 16-18 Ann Arbor, Mich.
Ready for Rails Ruby Wkshp June 23-24 Ann Arbor, Mich.
Ruby on Rails Wkshp June 25-27 Ann Arbor, Mich.
Ruby Plus Rails Combo Wkshp June 23-27 Ann Arbor, Mich
Please visit http://Lea... for all the details.