Measuring against a future time in Ruby -
i'd able run method measure time.now against future date, this:
def graduated? time.now == # future date ? (puts "congrats!") : (puts "not there yet!") end i've tried entering syntax ruby docs future date such: 2015-8-7
but not correct. correct syntax on how hard code future date compare against?
if enter "2015-8-7" that's string, you'll want time object. should point in right direction:
2.2.0 :001 > other = time.new(2015, 8, 7) => 2015-08-07 00:00:00 -0500 2.2.0 :002 > time.now < other => true 2.2.0 :003 > time.now > other => false you can use date object, , date.today, date.new(2015, 8, 7) , similar results.
Comments
Post a Comment