Questions regarding DT_TIME

Paul Cohen <[email protected]> Thu, 2 Apr 2009 10:55:05 +0200
Newsgroups gmane.comp.lang.eiffel.gobo.devel
Message-ID <[email protected]>
Hi,

I have implemented a very simple DT_STOPWATCH class for doing simple
timing stuff (ie. start, stop & elapsed_time). In that class I use the
feature DT_TIME.duration. To my surprise I occasionally get negative
seconds and milliseconds.

In DT_TIME there is the feature:

    duration (other: like Current): DT_TIME_DURATION is
            -- Duration between `other' and `Current'
        do
            Result := time_duration (other)
        end

I then realize that DT_TIME.duration uses DT_TIME.time_duration which does:

    create Result.make_precise (hour - other.hour, minute -
other.minute, second - other.second, millisecond - other.millisecond)

where Result & other are DT_TIME. I now realize that I must use
DT_TIME.canonical_duration to get the result I expect since it
calculates the difference (correctly) based on the milliseconds count
of both DT_TIME instances. My questions are:

   1. Why doesn't DT_TIME.duration use DT_TIME.canonical_duration?

   2. When & why does anyone want to use DT_TIME.time_duration in its
current implementation?

   3. DT_TIME.time_duration has a misleading name. Better is
DT_TIME.time_unit_differences or something like that which says what
it does.

   4. Is the Gobo project interested in my DT_STOPWATCH class?

I'm using:
  * Gobo 3.8
  * EiffelStudio: 6.2
  * On Linux/gcc

/Paul

-- 
Paul Cohen
www.seibostudios.se
mobile: +46 730 787 035
e-mail: [email protected]

------------------------------------------------------------------------------