"Passing Go" in a (python) date range

Posted by anonymous coward on Stack Overflow See other posts from Stack Overflow or by anonymous coward
Published on 2010-06-14T21:42:34Z Indexed on 2010/06/14 21:52 UTC
Read the original article Hit count: 127

Filed under:
|
|
|
|

The Rules:
An employee accrues 8 hours of Paid Time Off on the day after each quarter. Quarters, specifically being:

  • Jan 1 - Mar 31
  • Apr 1 - Jun 30
  • Jul 1 - Sep 30
  • Oct 1 - Dec 31

The Problem
Employees will use an automated system to request paid time off, possibly occurring in the past, as well as the future. Requests should only be accepted if the employee has (or will have) that time available.

For instance, if an employee only has 1 Day of Paid Time Off currently available (currently being January 20th), but is requesting 2 Days of Paid Time Off, beginning September 20th, the system should take into account that the employee would have accrued enough time off by then and allow the request. (Obviously ignoring that the employee may use up existing time before that date).

I'm currently using Python, and wondering what the correct approach to something like this would be.

I'm assuming that using DateTime objects, and possibly the dateutil module, would help here, but my brain isn't wrapping around this problem for some reason.

© Stack Overflow or respective owner

Related posts about python

Related posts about datetime