From: Mike McKinney Date: 2008-01-14T04:39:27+09:00 Subject: Re: regualr expression (need help) ------=_Part_6762_30972931.1200253165987 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Henry, should do : ValidDate = File.readlines('someFile.txt').to_s.grep(/Not After/) instead of : ValidDate = File.open("someFile.txt").readlines.to_s.grep(/Not After/) Sebastian corrected me once... File.open without a block will leave the file pointer open... :) M On Jan 13, 2008 12:47 PM, Heinrich Piard wrote: > Daniel Finnie wrote: > > I would create a time object and then format it how you like. > > > > Time.parse(string).strftime(format_string) > > > > Look up the docs for Time#strftime to determine the format string. > > > Guys - thanks a lot. > It works just great!! > > Here the snipped: > ValidDate = File.open("someFile.txt").readlines.to_s.grep(/Not After/) > #puts 'Certificate is valid ' + ValidDate.to_s > CertValidDate = Time.parse(ValidDate.to_s).strftime("%Y-%d-%m") > #puts CertValidDate > > Now I can do my comparison with actualDate and CertValidDAte and I am > able to create an alarm. > > Thanks!!! > > bye > Henry > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_6762_30972931.1200253165987--