[PYTHON DB-SIG] [comp.lang.python] Date-Time requirements (esp. for databases)
Jim Fulton
jim.fulton@digicool.com
Wed, 30 Oct 1996 09:26:14 -0500
Harri Pasanen wrote:
>
> Jim Fulton writes:
> > W. Craig Trader wrote:
> > >
> > > > arithmetic - difference between two dates. adding dates - it should be
> > > > possible to produce a DateTime object representing "1 week"
> > > > and say DateTime(now) + DateTime("1 week").
> > >
> > > I think you're wrong here - there should be multiple types: DateTime, as
> > > already discussed, and Interval, which would represent a signed quantity
> > > of a generic unit (ie: 10 minutes or 2 hours or 1 week or 5 years), or
> > > possibly a combination. Math would look like this:
> > >
> > > Interval + Interval => Interval
> > > Interval - Interval => Inverval
> > > DateTime + Interval => DateTime
> > > DateTime - Interval => DateTime
> > > DateTime - DateTime => Interval
> > >
> > > Since we're talking about databases, the types should try to stick fairly
> > > close to SQL, and SQL/92 already has provisions for DateTimes and
> > > Intervals.
> >
> > 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?
Jim
--
Jim Fulton Digital Creations
jim@digicool.com 540.371.6909
## Python is my favorite language ##
## http://www.python.org/ ##
=================
DB-SIG - SIG on Tabular Databases in Python
send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
=================