Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- from emailer_live import mailer
- from monthly_tally import EOM
- ''' calculates shift pattern of 6 nights 3 off for a set period, along with the shidts and hours.worked in every month for that period '''
- class Shift_Pattern_Dates:
- def pattern_generator_2(self, sdate, edate, ons, offs):
- """ons who the shifts scheduled amd offs the immediate off days for the corresponding shift in ons """
- result =''
- new_month = False
- startdate = datetime.datetime.strptime(sdate, '%d/%m/%Y')
- enddate = datetime.datetime.strptime(edate,'%d/%m/%Y' )
- monthly_tally = 0
- oneday = datetime.timedelta(days = 1)
- current_month = startdate.month
- while startdate <= enddate:
- for i in range(0, 6):
- current_month, startdate, result, monthly_tally = EOM.tally(current_month, startdate, new_month, monthly_tally)
- mnth_name = startdate.strftime('%B')
- if new_month:
- result += '='*40+'\n'
- result += mnth_name + ': Shifts = ' + str(monthly_tally)+ ' Hours Total = ' + str(monthly_tally * 12) +'\n' +'='*40+'\n'
- monthly_tally = monthly_tally + 1
- result += startdate.strftime('%A, %B %d, %Y') + ' - On' +'\n'
- startdate = startdate + oneday
- #skip current day and following 2 days
- for j in range(0, 3):
- current_month, startdate, result, monthly_tally = EOM.tally(current_month, startdate, new_month, monthly_tally)
- mnth_name = startdate.strftime('%B')
- if new_month:
- result += '='*40+'\n'
- result += mnth_name + ': Shifts = ' + str(monthly_tally)+ ' Hours Total = ' + str(monthly_tally * 12) +'\n' +'='*40+'\n'
- result += startdate.strftime('%A, %B %d, %Y') + ' - Off' + '\n'
- startdate = startdate + oneday
- return result + summary
- c = Shift_Pattern_Dates()
- e = mailer()
- # startdate, enddate, days, off, nights, off
- shifts_and_tally = c.pattern_generator_2('27/01/2018', '31/12/2018', [3,0],[3,3])
- print(shifts_and_tally)
- e.smtp_mailer(shifts_and_tally, 'Rota For Period: 27/01/2018 - 31/12/2018', 'dsthecheduler', ['denis.seale@gmail.com'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement