[PYTHON DB-SIG] [comp.lang.python] Date-Time requirements (esp. for databases)

Harri Pasanen pa@tekla.fi
Wed, 30 Oct 1996 23:12:03 +0200


Jim Fulton writes:
> Harri Pasanen wrote:
> > >
> > > What is the rational for using a dedicated Interval class rather than
> > > just
> > > using numbers with agreed units. (See my other note?)  Is the benefit
> > > worth the added class?
> > 
> > I'd vote for Interval class, as the convenient unit depends on the
> > application domain.  I can easily imagine applications where even
> > subsecond intervals are interesting, as well as those where a day is a
> > small unit.
> 
> Even if the DateTime class exported unit conversion attributes?
> If I want to work in, say milliseconds, I can easily do:
> 
>   spam=(date1-date2)/DateTime.lengthOfSecond * 1000
> 
> without introducing a separate Interval class.  Isn't this enough?
> If not, then how would an Interval class be used to solve this problem, 
> and why would it be better?
> 

I reread your previous note (somehow I missed the conversion attribute
suggestion), and agree that this would be a workable solution.

With my idea of an Interval class, the above would look like something like

spam = Interval(date1-date2).milliSeconds()

But I'd probably have to elaborate the Interval class a bit further to
see if I'm making sense to myself, and probably would have to do a
prototype implementation.

Somehow just working with the concept of DateTimes, which are points
in the linear time vector, and Intervals, which are line segments on the
same time vector, seems very intuitive to me.

That said, I won't have time do actual implementation in near future,
so I accept with gratitude any implementation. 

Harri

=================
DB-SIG  - SIG on Tabular Databases in Python

send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
=================