On Wed, Mar 19, 2008 at 12:13:42AM +0500, Mamkin Mansur wrote:
> If I need timestamp (datetime) relation in my DB-class, how can I do
> it? I need this for sorting objects by datetime.

The best way is to define a relation in that class which holds a date
and a time:

   (class +MyClass +Entity)
   ...
   (rel ts  (+Ref +Bag) NIL ((+Date)) ((+Time)))   # Timestamp
   ...



Then you could create new objects with a timestamp

   (new! '(+MyClass) .. 'ts (list (date) (time T)) ..)


or put a time stamp on existing objects

   (put!> ObjOfMyClass 'ts (list (date) (time T)))


Note that calling 'time' with an argument 'T' is a new feature of the
next release (due to the end of this month). It guarantees atomicity of
'date' followed by 'time'.


For example, to find all objects that have a timestamp within a given
range

   (collect 'ts '+MyClass
      (list (date 2008 3 15) (time 12 30))
      (list (date 2008 3 19) (time 17 10)) )

Cheers,
Alex
-- 
   Software Lab. Alexander Burger
   Bahnhofstr. 24a, D-86462 Langweid
   [EMAIL PROTECTED], www.software-lab.de, +49 8230 5060

Reply via email to