2024-03-07 22:40:32 +09:00
|
|
|
#!/usr/bin/ruby
|
2024-03-19 07:43:50 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-03-06 22:31:13 +09:00
|
|
|
require 'date'
|
2024-03-07 22:40:32 +09:00
|
|
|
require 'optparse'
|
2024-03-06 22:31:13 +09:00
|
|
|
|
2024-03-07 22:40:32 +09:00
|
|
|
year = Date.today.year
|
|
|
|
month = Date.today.month
|
2024-03-19 07:43:50 +09:00
|
|
|
week = %w[日 月 火 水 木 金 土]
|
2024-03-08 22:33:32 +09:00
|
|
|
|
|
|
|
opt = OptionParser.new
|
2024-03-09 09:13:53 +09:00
|
|
|
opt.on('-m month') { |v| month = v.to_i }
|
|
|
|
opt.on('-y year') { |v| year = v.to_i }
|
|
|
|
opt.parse(ARGV)
|
2024-03-08 22:33:32 +09:00
|
|
|
|
2024-03-19 07:43:50 +09:00
|
|
|
first_day = Date.new(year, month, 1)
|
|
|
|
last_day = Date.new(year, month, -1)
|
|
|
|
puts "#{month.to_s.rjust(7)}月\s#{year}"
|
2024-03-07 22:40:32 +09:00
|
|
|
puts week.join(' ')
|
2024-03-19 07:43:50 +09:00
|
|
|
print "\s\s\s" * first_day.wday
|
|
|
|
|
|
|
|
(first_day..last_day).each do |date|
|
2024-03-19 19:58:08 +09:00
|
|
|
day_string = date.day.to_s.rjust(2, "\s")
|
2024-03-19 07:43:50 +09:00
|
|
|
day_string = "\e[7m#{day_string}\e[0m" if date == Date.today
|
2024-03-19 19:58:08 +09:00
|
|
|
print "#{day_string}\s"
|
2024-03-19 07:43:50 +09:00
|
|
|
puts if date.saturday?
|
2024-03-07 22:40:32 +09:00
|
|
|
end
|
2024-03-19 07:43:50 +09:00
|
|
|
puts
|