Creating a 2021 weekly calendar (refill for personal organizer) using Ruby

Purpose:

Creating a weekly calendar.

background:

The size of the refill of the personal organizer (82mmW x 140mmL) is special, and although I started using it, it was difficult to obtain it, so I thought about making it by hand in the past. At that time, I had made a custom-made refill paper, and there was a surplus of blank paper at that time, so I thought about making it by hand next year for the first time in a while. Since it is once a year, it can be handmade, but since there is a special programming environment, let's create a mechanism that can automatically output a calendar every year. That's why I programmed it.

printing:

Use the "mail merge" function of the word processing software. Therefore, calendar data for mail merge may be created. The template for "mail merge" is a template that is displayed for one week in a spread as shown in the figure below. The same applies to a template that packs one week on one side like an efficiency notebook. L_andR_.png Data: One record per week, so if you have a calendar database like the one shown below, you can use it for mail merge. I made this table with ruby. weekly.png

The code of ruby is as follows.

.weekly_calendar.rb



# weekly

require 'date'
day = Date.new(2020,12,28)  #Last Monday of December starting on Monday
last = Date.new(day.year+1, day.month, day.mday)
weekdays = {0 => 'Day', 1 => 'Month', 2 => 'fire', 3 => 'water', 4 => 'wood', 5 => 'Money', 6 => 'soil'}
 while day < last do
  records=Array.new
  records.push(day.strftime("%Y%W,%Y,%W"))
  dday = day
    while dday < day+7 do 
     wday = weekdays[dday.wday]
     records.push(dday.strftime("%b,%-m,%d,%w,#{wday},%a,"))
     dday = dday+1
    end
  print records.join(',')
  print  "\n"
  day = day+7
 end

The header file was output with the following code and pasted on top of the above output. If you output csv and load it into libreoffice calc, it will be "mail merge" data.

.header.rb


# weekly header

printf "%s,%s,%s,","yrwk","yr","wkwk"
printf "%s,%s,%s,%s,%s,%s,%s,","mte1","mtn1","dyn1","wkn1","wkj1","wke1","s1"
printf "%s,%s,%s,%s,%s,%s,%s,","mte2","mtn2","dyn2","wkn2","wkj2","wke2","s2"
printf "%s,%s,%s,%s,%s,%s,%s,","mte3","mtn3","dyn3","wkn3","wkj3","wke3","s3"
printf "%s,%s,%s,%s,%s,%s,%s,","mte4","mtn4","dyn4","wkn4","wkj4","wke4","s4"
printf "%s,%s,%s,%s,%s,%s,%s,","mte5","mtn5","dyn5","wkn5","wkj5","wke5","s5"
printf "%s,%s,%s,%s,%s,%s,%s,","mte6","mtn6","dyn6","wkn6","wkj6","wke6","s6"
printf "%s,%s,%s,%s,%s,%s,%s\n","mte7","mtn7","dyn7","wkn7","wkj7","wke7","s7"

Holiday information will be corrected manually. I would like to improve it so that it can be automatically inserted once the data is prepared, but the schedule is undecided because it is a work once a year.

Recommended Posts

Creating a 2021 weekly calendar (refill for personal organizer) using Ruby
Creating a calendar using Ruby
[For beginners] Procedure for creating a controller using rails
A memorandum for creating an extended logger using org.slf4j.Logger
Creating a docker host on AWS using Docker Machine (personal memorandum)
Procedure for publishing an application using AWS (4) Creating a database
Create a fortune using Ruby
Explanation of Ruby on rails for beginners ③ ~ Creating a database ~
[Android] Create a calendar using GridView
How to build a Ruby on Rails environment using Docker (for Docker beginners)
Creating a user authentication function using devise
[Personal memo] Writing a file using BufferedWriter
[Personal memo] Reading a file using BufferedReader