Created
January 4, 2016 12:16
-
-
Save cpetschnig/90950cf0657cc65a3aaf to your computer and use it in GitHub Desktop.
Creates a structure for your custom spreadsheet calender
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
# encoding: UTF-8 | |
require 'active_support/all' | |
MONTHS = %w(Januar Februar März April Mai Juni Juli August September Oktober November Dezember) | |
DAYS = %w(So Mo Di Mi Do Fr Sa) | |
year = 2016 | |
months = (1..12).map do |month| | |
date = Date.new(year, month, 1) | |
beginning_of_next_month = date.next_month | |
month_column = [] | |
begin | |
month_column << %|#{DAYS[date.wday]};#{date.day};| | |
date += 1 | |
end while date != beginning_of_next_month | |
month_column | |
end | |
4.times do |quarter| | |
puts (0..2).map { |m| MONTHS[quarter * 3 + m] }.join(';') | |
(0..30).each do |day| | |
output = (0..2).map do |miq| | |
day_str = months[quarter * 3 + miq] && months[quarter * 3 + miq][day] | |
day_str || ';' | |
end | |
puts output.join(';') | |
end | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment