Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > RFC-822 dates into Ruby dates

Reply
Thread Tools

RFC-822 dates into Ruby dates

 
 
kellygreer1
Guest
Posts: n/a
 
      06-08-2008
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
http://www.velocityreviews.com/forums/(E-Mail Removed)
change nospam into yahoo


 
Reply With Quote
 
 
 
 
Eric I.
Guest
Posts: n/a
 
      06-08-2008
On Jun 8, 6:12*pm, kellygreer1 <(E-Mail Removed)> 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://LearnRuby.com for all the details.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to use dates earlier than 1900 (Time library says out of range for dates < 1900) me@benjaminarai.com Ruby 1 07-17-2007 02:25 PM
FAQ Dates; Opera Dates. Dr J R Stockton Javascript 0 06-18-2007 03:51 PM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
Dates dates dates dates... SQL and ASP.NET David Lozzi ASP .Net 1 09-30-2005 02:18 PM
Dates! Dates! Dates! PW ASP General 4 08-09-2004 04:42 PM



Advertisments