Finding specific date ranges

kyosohma at gmail.com kyosohma at gmail.com
Fri Sep 7 09:35:58 EDT 2007


On Sep 7, 2:47 am, Tim Golden <m... at timgolden.me.uk> wrote:
> Zentrader wrote:
> > On Sep 6, 7:56 am, kyoso... at gmail.com wrote:
> >> December 31, 2006    January 13, 2007 # doesn't earn
> >> January 14, 2007        January 27, 2007 # does earn
> >> January 28, 2007        February 10, 2007 # doesn't
> >> February 11, 2007       February 24, 2007 # does
>
> > Am I over simplifying if I say that since it appears to be a two week
> > pay period, the date has to be greater than the 11th unless the first,
> > or first and second, are on a weekend, in which case it would be > 12
> > or > 13?  Or a reasonable facsimile thereof, depending on whether or
> > not the two week period is Saturday through Friday.
>
> I think it's one of those things where the neatest answer
> could well depend on the sort of heuristic you mention. As
> a rule, when I come across this kind of requirement, I tend
> to put the most general solution in place, unless a *real*
> optimisation is clearly called for. In my experience, this
> makes it much easier for the next person who looks at the
> code, typically years later, even if that's me!
>
> (This is has just happened to me this week, having to review
> a date-related calculation to do the repost frequency of the
> adverts my company deals with. I wrote the original code five
> years ago, and commented it intelligently, but I *still* had
> to work through the code twice when we had a problem with a
> particular cycle!)
>
> TJG

I think it's foolish NOT to comment code unless it's very well self-
documented. Even then, a couple lines of comments can be helpful. I've
had to translate a bunch of Kixtart code into Python and none of it
was commented and it wasn't well formed code either.

And I've had the same thing happen with code that's only a year old.
I'll read it and then go "what the?!" It's just not possible to
remember every line of code you write. I wish it was.

Mike




More information about the Python-list mailing list