From: louis Date: 2008-01-14T04:19:16+09:00 Subject: Re: regualr expression (need help) sorry to post what might be a moronic question, but i although Time.parse shows up in the online core docs, Time.parse isn't a method on any machine of mine. e.g. irb(main):001:0> Time.methods.sort => [:"!", :"!=", :"!~", :<, :<=, :<=>, :==, :===, :=~, :>, :>=, :__id__, :__send__, :_load, :allocate, :ancestors, :at, :autoload, :autoload?, :class, :class_eval, :class_exec, :class_variable_defined?, :class_variable_get, :class_variable_set, :class_variables, :clone, :const_defined?, :const_get, :const_missing, :const_set, :constants, :define_singleton_method, :display, :dup, :enum_for, :eql?, :equal?, :extend, :freeze, :frozen?, :gem, :gm, :hash, :include?, :included_modules, :inspect, :instance_eval, :instance_exec, :instance_method, :instance_methods, :instance_of?, :instance_variable_defined?, :instance_variable_get, :instance_variable_set, :instance_variables, :is_a?, :kind_of?, :local, :method, :method_defined?, :methods, :mktime, :module_eval, :module_exec, :name, :new, :nil?, :now, :object_id, :private_class_method, :private_instance_methods, :private_method_defined?, :private_methods, :protected_instance_methods, :protected_method_defined?, :protected_methods, :public_class_method, :public_instance_method, :public_instance_methods, :public_method, :public_method_defined?, :public_methods, :public_send, :remove_class_variable, :respond_to?, :send, :singleton_methods, :superclass, :taint, :tainted?, :tap, :to_enum, :to_s, :untaint, :utc] (from an ubuntu box running 1.9.0--but i don't get a parse on 1.8.6 on ubuntu or mac) in fact, whytheluckstiff's online ruby terminal at hobix.com *does* have Time#parse. and you all are using it. any ideas? where did i drop the ball? thanks in advance. 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/. > >