From 92e3050f67514fba50d303bb0930d6329e4cba72 Mon Sep 17 00:00:00 2001 From: Rikuoh Date: Wed, 6 Mar 2024 22:31:13 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=8F=E3=83=AA=E3=83=9C=E3=83=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cal.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cal.rb diff --git a/cal.rb b/cal.rb new file mode 100644 index 0000000..94c0c1e --- /dev/null +++ b/cal.rb @@ -0,0 +1,32 @@ +require 'date' + +time = Time.now.localtime +year = time.year.to_i +month = time.month.to_i +currentday = time.day # 現在日 +startwday = Date.new(year,month,1).wday # その月の最初の曜日 +endmonth = Date.new(year,month,-1) # その月の日数 +endwday = time.wday # その月の最後の曜日 + + +a = Date.new(2024, 3, 6) +puts "\t#{a.month}月\s#{a.year}" +b = %w(日 月 火 水 木 金 土) +b.each do |week| + print "\s#{week}" +end +days = (1..31).to_a +days.each do |day| + if day == 1 + print "\n\s\s#{day}" + elsif day % 7 == 0 && day != 7 + print "\s#{day}\n" + elsif day == 7 + print "\s\s#{day}\n" + elsif day >= 10 + print "\s#{day}" + else + print "\s\s#{day}" + end +end +