From: Robert Dober Date: 2007-04-30T19:47:45+09:00 Subject: Re: Ruby date conversion On 4/30/07, Singeo wrote: > Hi, I have a text file with dates stored in the following format: > > 30/04/07 16:52:00 +0800 > > I need to convert these dates to RFC-822 so the above would become: > > Mon, 30 Apr 2002 16:52:00 +0800 > > Can someone help me with the Ruby code required to do this? I've bveen > trying to do it using Time.parse but with no success. > > Thanks > I do this as lazily as possible: irb(main):009:0> x="30/04/07 16:52:00 +0800" => "30/04/07 16:52:00 +0800" irb(main):010:0> y,rest = x.split(/\s+/,2) => ["30/04/07", "16:52:00 +0800"] irb(main):011:0> s=Date.strptime(y,"%y/%m/%d") => # irb(main):024:0> s.strftime("%a, %d %b %y") << rest => "Sun, 07 Apr 3016:52:00 +0800" HTH Robert -- You see things; and you say Why? But I dream things that never were; and I say Why not? -- George Bernard Shaw