On 31 Mar 2007 14:21:23 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:


I'm working on a website for some firefighters that want to be able to
sign-up for overtime and I need some help figuring out a date related
problem.

Here's the scenario:

Four groups of firefighters (group1, group2, group3, group4). Each
group works a 24 hr shift. So group1 works April 1, group2 works April
2, group3 works April 3, group4 works April 4, group 1 works April 5,
etc. It just keeps rolling like this forever into next year, etc.

I need to come up with a methodology for the following:


I have a small program for you, hope this helps.

dutycycle.py
----------------

#!/usr/bin/env python

"""Data Cycle Finder
The input date is of the form dd/mm/yyyy.
"""

from datetime import date
import sys

def dutyfinder(_date):
   start = date(2007,1,1) # the duty cycle started on 1st jan 2007
   return (date.toordinal(_date)-date.toordinal(start))%4


indate = sys.argv[1].split('/')
enddate = date(int(indate[2]),int(indate[1]),int(indate[0]))
onduty = int(dutyfinder(enddate)) + 1
print onduty

---------------------------

Now, call this program with your input date in dd/mm/yyyy format. You can
modify the code to suit mm/dd/yyyy format . Also modify the start date which
is now 1st January 2007. The output will be the number of the group.

Ex: $ python dutycycle.py 10/1/2007
output: 2

--
With Regards


Parthan "Technofreak"

http://technofreakatchennai.wordpress.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to