Skip to content

Instantly share code, notes, and snippets.

@jspooner
Last active June 4, 2016 21:38
Show Gist options
  • Save jspooner/45f203e33099880613acbfc36847f80a to your computer and use it in GitHub Desktop.
Save jspooner/45f203e33099880613acbfc36847f80a to your computer and use it in GitHub Desktop.
Regular Schedule Generator
require 'active_support'
require 'date'
def format_date d
d.strftime("%D %I:%M %p")
end
week_one_start = DateTime.parse("2016-03-03 4:00 PM")
week_one_end = DateTime.parse("2016-03-06 5:30 PM")
week_two_start = DateTime.parse("2016-03-09 4:00 PM")
week_two_end = DateTime.parse("2016-03-11 5:30 PM")
puts "Start Time, End Time, Week Rotation"
puts "#{format_date(week_one_start)},#{format_date(week_one_end)},week one"
puts "#{format_date(week_two_start)},#{format_date(week_two_end)},week two"
until week_one_start > DateTime.parse("2027-03-29")
week_one_start = week_one_start + 14
week_one_end = week_one_end + 14
week_two_start = week_two_start + 14
week_two_end = week_two_end + 14
puts "#{format_date(week_one_start)},#{format_date(week_one_end)},week one"
puts "#{format_date(week_two_start)},#{format_date(week_two_end)},week two"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment