confused on calculating date difference in days.

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Oct 16 04:28:14 EDT 2007


On Tue, 16 Oct 2007 18:10:54 +1000, Ben Finney wrote:

> Marc 'BlackJack' Rintsch <bj_666 at gmx.net> writes:
> 
>> On Tue, 16 Oct 2007 12:33:33 +0530, krishnakant Mane wrote:
>> 
>> > firstly, I can't get a way to convert a string like "1/2/2005" in
>> > a genuan date object which is needed for calculation.
>> 
>> Why?  Split the string up, convert the parts to `int` and just
>> create a `datetime.date` object.
> 
> What, re-implement 'strptime' in every program that needs it? And then
> debug the result every time?

Yes.  Seems easier to me.  :-)

> Even if one doesn't have Python 2.5 or above, surely getting the
> string parsed into int values by the standard 'time.strptime' is
> better than re-implementing it every time.
> 
>> Maybe you should read the docs next time.  ;-)
> 
> Back at you.

Got me.  I didn't know that `datetime` has a `strptime` now.  I just
looked at `date`.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list