Hi all This is regarding time class in ruby. I save the current time in the mysql table which has the column type "TIME" which stores only the time not the date. But when im trying to retrieve it as a Time object in ruby it has asinges both date and time components. Since there is no date factor in the table it automatically assigns a default value as a date. As a result it is hard to compare only times without doing a special mechanism. So is there a specific way to get only the time factor without date? (I know that this can be done by splitting the time object. But then we cant do direct time caparisons easily) Thanx in advance Shamika
It will always do that. If you want you can extend Time to create your on method like "show_time" for example which you can then have return the time only for you. That way you can run the comparisons easy as both the date you get from the DB and the you are checking against can use the same method.
Hi, I'm using bigints in db and store unixtime value - instead of default datetime data type.
then have helpers like (including localization)
return '' if date.nil? || date==0 l(Time.at(date), :format => :ddate)
return '' if date.nil? || date==0 l(Time.at(date), :format => :dtime)
and because date/time is stored as integer, there's no problem to make simple diffs (in db query too)