Last active
          August 29, 2015 14:01 
        
      - 
      
 - 
        
Save trcook/ff6e90b086016eb3977b to your computer and use it in GitHub Desktop.  
    This is a quick and easy script that will generate a list of dates for each workday over an interval. I use it to generate a list of dates for classes in a semester and keep track of the number of weeks in the semester
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env ruby | |
| require 'date' | |
| dates=Array.new() | |
| c = Date.new(2014,07,04) | |
| b= Date.new(2014,06,02) | |
| max_weeks= (c-b)/7.to_f | |
| max_weeks=max_weeks.ceil | |
| course_day=0 | |
| (c-b).to_int.times do |t| | |
| w_day= Date::DAYNAMES[(b+t).wday] | |
| date_day=(b+t).day | |
| date_month=(b+t).month | |
| week=(t/7)+1 | |
| unless w_day=="Saturday" or w_day=="Sunday" | |
| course_day+=1 | |
| dates<<{"course_day"=>course_day,"weekday"=>w_day,"month"=>date_month,"date_day"=>date_day,"week"=>week} | |
| end | |
| end | |
| File::open( 'my_dates'+ '.txt', 'w' ) do |f| | |
| dates.each do |t| | |
| f<< %{## Course Day: #{t["course_day"]} Week #{t["week"]} Date: #{t["month"]}-#{t["date_day"]} \ | |
| Weekday: #{t["weekday"]} | |
| Weeks Remining:#{max_weeks-t["week"]} Days Remaining: #{max_weeks*5-(t["course_day"]+1)} | |
| \n\n} | |
| end | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment