I have a method for returning the number of weeks based on a run_date
and end_date in my model:
def weeks
# logger.debug "** Start date: #{self.run_date} End date: #
{self.end_date}"
# logger.debug "** Difference: #{self.end_date - self.run_date}"
( ( self.end_date - self.run_date ) / 60 / 60 / 24 / 7 ).to_i
end
This was frustrating me for the last couple of hours because I
couldn''t figure out why I was getting wrong results or unit test
failure whether I added the division by 60/60/24/7 or not... Until I
added the logger.debug calls:
Test:
** Start date: Wed Sep 27 00:00:00 PDT 2006 End date: Wed Oct 25
00:00:00 PDT 2006
** Difference: 2419200.0
Development:
** Start date: 2006-09-27 End date: 2006-10-25
** Difference: 28
Both MySQL databases use the DATE type for these columns, not
DATETIME. I think I can find a way around this by doing some casting,
but I''d sure like to know if anyone has an answer for this?
I''m just
learning Rails and I''d sure like to understand what could be
happening here.
--Andrew
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---