Last active
January 20, 2017 15:07
-
-
Save spleenteo/2f4fb8c5ca1caf53bb92 to your computer and use it in GitHub Desktop.
weekly calendar for a specific year
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/ruby | |
require 'date' | |
year = if ARGV.length > 0 | |
ARGV.first.to_i | |
else | |
Time.now.year | |
end | |
first_iteration = true | |
Date.new(year, 01, 01).upto(Date.new(year, 12, 31)) do |day| | |
if day.cwday == 1 | |
end_day = day + 6 | |
if day.month != end_day.month || day.month != (day - 1).month || first_iteration | |
puts "W#{day.strftime('%V, %d')} - #{(end_day).strftime('%d %b')}" | |
else | |
puts "W#{day.strftime('%V, %d')} - #{end_day.strftime('%d')}" | |
end | |
first_iteration = false | |
end | |
end | |
puts "calendar for the year #{year}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment