In SQL, there is a data type
TIME which holds time of day information without date information. There is no equivalent class in Ruby. Rails (ActiveRecord) deals with this by adding some dummy date data and using the standard Ruby
Time class. Currently the dummy date used is 2000-01-01, though since I can’t find any documentation on this, I guess it could be changed to something else in the future.
This means you can run into some odd issues if you aren’t careful when comparing values from SQL
TIME columns with times in your code.
For example, if you have a record
r in your database with the value “13:30:00″ stored in a column called
arrival_time of SQL data type
Time.parse("2000-01-01 13:30") == r.arrival_time # unless the dummy date AR uses has changed "13:30:00" == r.arrival_time_before_type_cast Time.parse("13:30") != r.arrival_time # unless today is 1st January 2000