Hi all
In all my current projects that use dm-timestamps, I run into an issue
with the use of DateTime. Because, when using the DataObjects
adapter, it saves to a precision of one second, writing specs is very
hard. To prove that one object is saved after another, you have to
introduce a delay of >= 1s to be sure of the order.
However, Time saves to a precision of microseconds. Because of this,
I have the following section in all my Merb init.rb files:
DataMapper::Timestamp::TIMESTAMP_PROPERTIES = {
:updated_at => [ Time, lambda { |r, p| Time.now } ],
:updated_on => [ Date, lambda { |r, p| Date.today } ],
:created_at => [ Time, lambda { |r, p| r.created_at || (Time.now
if r.new_record?) } ],
:created_on => [ Date, lambda { |r, p| r.created_on ||
(Date.today if r.new_record?) } ],
}.freeze
I just wondered, is there any reason why dm-timestamps can't use Time
instead of DateTime by default? It would increase the precision of
the timestamp data, but there may be issues I'm unaware of.
Thanks for any input
Ashley
--
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran
http://aviewfromafar.net/
http://twitter.com/ashleymoran
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---