It should be pointed out that these lines work only when you have required 'active_support' or something, which requires it :)
On Oct 20, 11:55 pm, Bret Pettichord <[EMAIL PROTECTED]> wrote: > Here is some more cool stuff with dates. > > C:\>watir-console > >> 10.days.ago > => Fri Oct 10 21:50:46 +0100 2008 > >> 1.month.from_now > => Thu Nov 20 21:51:00 +0000 2008 > >> 2.weeks.since Time.local(2008,1,1) > => Tue Jan 15 00:00:00 +0000 2008 > >> Time.now - 1.day > => Sun Oct 19 21:52:10 +0100 2008 > >> Time.now + 6.years > => Mon Oct 20 21:52:22 +0100 2014 > > How do i know about this? I looked in the Ruby Cookbook, one of the top > 2 Ruby books recommended for Watir > Testers.http://www.io.com/~wazmo/blog/archives/2008_10.html#000287 > > Moochie wrote: > > Incase anyone needs to add or subtract days, months, years or all of > > the above from a known date the following works for me. > > > require 'date' > > #Date Add Function > > def date_add(mth,day,yr) > > #Set Date Variable > > @new_date = Date.today > > #Month calculations > > if mth != 0 > > @new_date = @new_date >> mth > > end > > #Day calculation > > if day != 0 > > @new_date = @new_date.+(day) > > end > > #Year calculation > > if yr != 0 > > @new_date = @new_date >> yr * 12 > > end > > #Returns new date > > return @new_date > > end > > @new_date = date_add(2,3,4) > > puts @new_date.strftime("%m/%d/%Y") --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Watir General" group. To post to this group, send email to watir-general@googlegroups.com Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/watir-general -~----------~----~----~----~------~----~------~--~---