User Tools

Site Tools


course_length

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

course_length [2019/05/05 19:08]
k2patel created
course_length [2020/08/10 02:35]
Line 1: Line 1:
-<code python | datecalc>​ 
-#​!/​usr/​bin/​env python3 
  
-from dateutil import rrule 
-import sys, getopt 
-import datetime 
- 
-#start_date = datetime.datetime.strptime('​5/​20/​2019',​ '​%m/​%d/​%Y'​) 
-#end_date = datetime.datetime.strptime('​7/​14/​2019',​ '​%m/​%d/​%Y'​) 
- 
-def main(argv): 
-   ​start_date = ''​ 
-   ​end_date = ''​ 
-   try: 
-      opts, args = getopt.getopt(argv,"​hs:​e:",​["​sdate=","​edate="​]) 
-   ​except getopt.GetoptError:​ 
-      print ('​datecalc -s <​start_date>​ -e <​end_date>'​) 
-      sys.exit(2) 
-   for opt, arg in opts: 
-      if opt == '​-h':​ 
-         print ('​datecalc -s <start date> -e <end date>'​) 
-         ​sys.exit() 
-      elif opt in ("​-s",​ "​--sdate"​):​ 
-         ​start_date = datetime.datetime.strptime(arg,​ '​%m/​%d/​%Y'​) 
-      elif opt in ("​-e",​ "​--edate"​):​ 
-         ​end_date = datetime.datetime.strptime(arg,​ '​%m/​%d/​%Y'​) 
-   ​weeks=rrule.rrule(rrule.WEEKLY,​ dtstart=start_date,​ until=end_date) 
-   print ('This course is: ', weeks.count(),​ ' Week Long') 
- 
-if __name__ == "​__main__":​ 
-   ​main(sys.argv[1:​]) 
-  ​ 
-</​code>​ 
course_length.txt ยท Last modified: 2020/08/10 02:35 (external edit)