Return to Snippet

Revision: 1350
at September 27, 2006 13:27 by gdonald


Updated Code
def days_between(date1, date2)
  yyyy1,mm1,dd1 = $3, $1, $2 if date1 =~ /(\d+)\/(\d+)\/(\d+)/
  date1_ts = Time.mktime(yyyy1,mm1,dd1).tv_sec
  yyyy2,mm2,dd2 = $3, $1, $2 if date2 =~ /(\d+)\/(\d+)\/(\d+)/
  date2_ts = Time.mktime(yyyy2,mm2,dd2).tv_sec
  (date2_ts - date1_ts)/60/60/24
end

Revision: 1349
at September 27, 2006 13:27 by gdonald


Initial Code
def days_between(date1, date2)
  yyyy1,mm1,dd1 = $3, $1, $2 if date1 =~ /(\d+)\/(\d+)\/(\d+)/
  date1_ts = Time.mktime(yyyy1,mm1,dd1).tv_sec
  yyyy2,mm2,dd2 = $3, $1, $2 if date2 =~ /(\d+)\/(\d+)\/(\d+)/
  date2_ts = Time.mktime(yyyy2,mm2,dd2).tv_sec
  (date2_ts - date1_ts)/60/60/24
end

Initial URL

                                

Initial Description

                                

Initial Title
Rails days between dates

Initial Tags

                                

Initial Language
Ruby