[PYTHON DB-SIG] [comp.lang.python] Date-Time requirements (esp. for databases)
Harri Pasanen
pa@tekla.fi
Wed, 30 Oct 1996 15:35:03 +0200
Jim Fulton writes:
> W. Craig Trader wrote:
> >
> > On Wed, 30 Oct 1996, Anthony Baxter wrote:
> >
> > > Other methods the DateTime objects should have:
> > >
> > > strftime - takes a format string, returns the date as a string in the
> > > specified format. ("%Y%M%D %H:%M:%S" -> "19961029 11:57:00")
> >
> > This is good, though it duplicates the existing `time' modules function.
> >
> > > 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.
Harri
=================
DB-SIG - SIG on Tabular Databases in Python
send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
=================