Schedule

Fetofs Ashu fetofs at gmail.com
Mon Apr 17 20:37:58 EDT 2006


I want to create a work schedule; I will have to input some names (in
alphabetical order) and the days they can't be working because they have a
license, are in vacation or are doing special services. Then, using that
information, the program would assign, from a Monday specified onwards, from
two weeks to two weeks for a period of 3 months (12 weeks), one person to
the morning and two to the afternoon, following the order.
However, if the person is not available in any day of that two weeks (input
given earlier); it is not allocated to that two weeks of work. Instead, it
is still the first of the list (it will be assigned in the future to the
next two weeks when there's nothing to impede the work).
Then the program will output the schedule to a file or the screen
(preferrably a file). I've included an example of only one period. The
impediment list is optional, but highly recommended if you can do it.If
anyone would want to program it for me, I'd be pleased. However, if you just
want to help me, I'll post the code and the problem:

day = int(raw_input("day: "))
month = int(raw_input("month: "))
year = int(raw_input("year: "))

for week in range(5):
    if day in calendar.monthcalendar(ano, mes)[week]:
        startweek = week

def definsemana():
    monthcalendar = calendar.monthcalendar(year, month)
    t1s = monthcalendar[startweek]
    if t1s[-1] == 0:
        startweek = 0
        if month < 12:
            month += 1
            for i in range(7):
                if t1s[i] == 0:
                    t1s[i] = calendar.monthcalendar(year,
month)[startweek][i]
                    startweek = 1
        else:
            month = 2
            year += 1

for day in t1s:
    print day, '\t',

This SHOULD get the day specified and output the week following it, however
it seems that it's outputting the first week of the month, regardless of the
input date (try 26 December 2005 as an example). Where's the problem?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060417/5b8d3509/attachment.html>


More information about the Python-list mailing list