by
Krull >> Thu, 9 Dec 1999 22:14:33 GMT
You could still pass back the TimeStamp, using tsc.Date.Integer as elapsed days instead of a date. With Decimal handling up to 23 significant digits,
you could add up lots of TimeStamps before having to sacrifice millisecond precision. Today's date is only a 7-digit number.
You are right you could store a time-interval in a timestamp, simply because it has sufficiently sized attributes to represent the 'state' of an interval. However, it will not provide the correct behaviour for a timestamp in that the date attribute contains elapsed days rather than a date value; you would need to be careful where ever such a pseudo timestamp was used. If your application requirements for computing date-time intervals are fairly low and you don't require a reusable solution, then you could represent an interval (the difference between two timestamps) as a decimal. I think this is a more acceptable compromise when you consider timestamp operations such as add or subtract interval. If your representation for an interval was a timestamp then the method signatures would need to take a timestamp eg. TimeStamp::addInterval(interval : TimeStamp) , which is misleading since you can't correctly pass it a true timestamp value. The alternative TimeStamp::addInterval(interval : Decimal) is slightly better but not ideal. I would prefer: TimeStamp::addInterval(interval : Interval), where interval is a user defined 'abstract data type' that encapsulates the state and behaviour of a time-interval. The implementation of a transient Interval class is straightforward;such a type could then be used in various TimeStamp, Date and Time operations. It would be nice to be able to define an Interval primitive-type (in a user schema), which would avoid the need to create and delete transient instances for computational purposes, but we can't do that just yet.
Note: that a day-time interval is a standard SQL type and most object frameworks provide some equivalent e.g. the ODMG type heirarchy has an Interval type and the MickeySoft MFC class hierarchy has a CTimeSpan class to do this job.