PEP 321: Date/Time Parsing and Formatting

Gerrit Holl gerrit at nl.linux.org
Tue Nov 18 08:13:44 EST 2003


John Roth wrote:
> > > * CVS-style or tar-style dates ("tomorrow", "12 hours ago", etc.)
> 
> The question here is class responsibilities. The datetime module is
> at a lower conceptual layer than the tarfile module. If the format
> is specific to the tarfile module, then it should be that module's
> responsibility to do the conversion. If it is a generally useful
> capability, then it should be the datetime module's responsibility.
> I'd like to see that discussed.

I think this example is generally useful, in two directions, both
as output and as input. It is also used by at, I think.

[second example]
> > >>> datetime.datetime.rfc2822("Tue, 13 Aug 1985, 15:03:00 +0100")
> > datetime(1985, 8, 13, 13, 5)

> As long as it's kept simple. I have a real problem with the second
> example; there are simply too many variations out there of the
> alphabetic month and day of the week to cover them all.

Actually, this already exists, but yields a timetuple rather than
a datetime object. It is called email.Utils.parsedate.

> > I prefer implementation #2. I'm never very happy with using constants
> > defined inside modules. I have to type 'module.CONSTANT' all the time...
> > I think a method is a very suitable way to do this.
> 
> I'd like to reiterate my comment from earlier: Internet data handling
> modules are at a higher logical level than datetime. If the formats are
> not generally useful, it should be the using module that is responsible
> for them: that is, the email and news modules for RFC822. If they
> are, then it should be datetime.

I agree. But I think rfc2822 _is_ useful beyond mail and news, as
are the other formats mentoined. Less useful formats can provide a
string in their own library, to be passed to either strptime or
strftime.

yours,
Gerrit.

-- 
162. If a man marry a woman, and she bear sons to him; if then this
woman die, then shall her father have no claim on her dowry; this belongs
to her sons.
          -- 1780 BC, Hammurabi, Code of Law
-- 
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Kom in verzet tegen dit kabinet:
	http://www.sp.nl/





More information about the Python-list mailing list