dubstep
1
consider this code stub
require ‘date’
today = DateTime.now
puts "Datetime.now returned: "+today.to_s
birthday = Date.new(2011, 10, 10)
days_to_go = today-birthday
puts "Days to go: "+days_to_go.to_s
It prints a number like -52632699/21600000
How do I get it to show true number of days, i.e. a number like 25
Thanks in advance!
Joe
On Thu, Sep 15, 2011 at 8:16 AM, joe c. [email protected] wrote:
require ‘date’
#today = DateTime.now
DateTime.now.to_date
birthday = Date.new(2011, 10, 10)
days_to_go = today-birthday
days_to_go = birthday - today # the future is built with bigger numbers

puts "Days to go: "+days_to_go.to_s
It prints a number like -52632699/21600000
puts days_to_go.class #=> Rational
How do I get it to show true number of days, i.e. a number like 25
puts “Days to go: #{days_to_go.to_i}”
HTH,
that works fine - thanks!
Joe