I am trying to use the Time property, to compare the last modification
time for a file. When I save a time, it appears to save the string in
the database fine but time always is read as 00:00:00. I assume there
is a conversion failing somewhere? Using datamapper 1.1.0 and ruby
1.8.7 pl334. If anyone has an idea what I'm doing wrong or how to fix
this, I would appreciate the help. Thanks
standalone testmodel.rb:
$: << File.join(File.dirname(__FILE__), "../lib")
require 'datamapper'
dbfile = File.join Dir.pwd, "test.db"
DataMapper.setup(:default, "sqlite3://#{dbfile}")
class Test
include DataMapper::Resource
property :id, Serial
property :mod_time, Time
end
DataMapper.auto_upgrade!
------- testing an entry:
> irb -r testmodel.rb
DataObjects::URI.new with arguments is deprecated, use a Hash of URI
components (./../lib/dm-do-adapter/adapter.rb:231:in `new')
irb(main):001:0> t = Test.new
=> #<Test @id=nil @mod_time=nil>
irb(main):002:0> t.mod_time = Time.now
=> Sun May 22 15:30:05 -0700 2011
irb(main):003:0> t.save
=> true
irb(main):004:0> Test.first
=> #<Test @id=1 @mod_time=Sun May 22 00:00:00 -0700 2011>
irb(main):005:0> RUBY_DESCRIPTION
=> "ruby 1.8.7 (2011-02-18 patchlevel 334) [x86_64-linux]"
-------- test.db:
> sqlite3 test.db
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select * from tests;
1|2011-05-22T15:30:05.065663-07:00
------- versions of gems installed:
datamapper-1.1.0
data_objects-0.10.6
dm-aggregates-1.1.0
dm-constraints-1.1.0
dm-core-1.1.0
dm-do-adapter-1.1.0
dm-migrations-1.1.0
dm-serializer-1.1.0
dm-sqlite-adapter-1.1.0
dm-timestamps-1.1.0
dm-transactions-1.1.0
dm-types-1.1.0
dm-validations-1.1.0
do_sqlite3-0.10.6
--
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.