confused on calculating date difference in days.

Ben Finney bignose+hates-spam at benfinney.id.au
Tue Oct 16 04:10:54 EDT 2007


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?

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.

-- 
 \           "If you do not trust the source do not use this program." |
  `\                                —Microsoft Vista security dialogue |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list