t = Time.now puts t puts t - 300
--- On Sun, 4/11/10, Rajiv Nanduani <[email protected]> wrote: From: Rajiv Nanduani <[email protected]> Subject: Re: [wtr-general] Re: how to compare time 10.30 PM with string "10:30 PM" To: [email protected] Date: Sunday, April 11, 2010, 11:08 AM still i need to less 5 minute from time how to do that On Sun, Apr 11, 2010 at 5:33 PM, Rajiv Nanduani <[email protected]> wrote: Hi All, Thanks to windy and all finally i got the way to do this require 'time' d = "Picks for this day lock at 01:00 PM ET" v =Time.parse((d.slice(/[0-9]{1,2}:[0-9]{1,2}.*(AM|PM)/i)).strip).strftime("%I:%M%p") d = "Picks for this day lock at 09:24 AM ET" b=Time.parse((d.slice(/[0-9]{1,2}:[0-9]{1,2}.*(AM|PM)/i)).strip).strftime("%I:%M%p") puts Time.parse(b).class # return time puts b.class # return string puts Time.parse(b) > Time.parse(v) # return false puts b > v # return true On Sun, Apr 11, 2010 at 1:51 PM, windy <[email protected]> wrote: require 'time' Time.parse("10:40 PM") > Time.now # return true So you can use '>' method on the Time class directly. please see the book 'rubycook' for more info. 在 Sun, 11 Apr 2010 12:37:40 +0800,Rajiv Nanduani <[email protected]> 写道: i think problem with comparison it actually comparing betwwen string not in time i check with this puts b.class # returns string puts v.class # returns string so now i change this string to time object but i do not no how to do this please help on this On Sat, Apr 10, 2010 at 11:56 PM, Rajiv Nanduani < [email protected]> wrote: Hi George , its not work when case AM another and another is PM require 'time' d = "Picks for this day lock at 01:00 PM ET" v = Time.parse((d.slice(/[0-9]{1,2}:[0-9]{1,2}.*(AM|PM)/i)).strip).strftime("%I:%M %p") d = "Picks for this day lock at 09:24 AM ET" b= Time.parse((d.slice(/[0-9]{1,2}:[0-9]{1,2}.*(AM|PM)/i)).strip).strftime("%I:%M %p") puts v < b # returns 'true' while it should be false On Sun, Apr 11, 2010 at 5:58 AM, George <[email protected]> wrote: <省略部分> -- RAJIV KUMAR <http://rajivkumarnandvani.wordpress.com/> <http://learnqtphelp.blogspot.com/> -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. You received this message because you are subscribed to http://groups.google.com/group/watir-general To post: [email protected] To unsubscribe, reply using "remove me" as the subject. -- RAJIV KUMAR <http://rajivkumarnandvani.wordpress.com/> <http://learnqtphelp.blogspot.com/> -- RAJIV KUMAR <http://rajivkumarnandvani.wordpress.com/> <http://learnqtphelp.blogspot.com/> -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. You received this message because you are subscribed to http://groups.google.com/group/watir-general To post: [email protected] -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. You received this message because you are subscribed to http://groups.google.com/group/watir-general To post: [email protected]
