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|
|
|
|
|
day_string = date.day.to_s.rjust(2, ' ')
|
|
|
|
day_string = "\e[7m#{day_string}\e[0m" if date == Date.today
|
|
|
|
print day_string
|
|
|
|
puts if date.saturday?
|
2024-03-07 22:40:32 +09:00
|
|
|
end
|
2024-03-19 07:43:50 +09:00
|
|
|
puts
|
|
|
|
|
|
|
|
# print "#{date.day.to_s.rjust(2)}\s"
|
|
|
|
# date += 1
|
|
|
|
# print "\n" if date.sunday?
|
|
|
|
# if date == Date.today && ARGV == [] # 引数なしなら現在日をハイライトする
|
|
|
|
# print "\e[7m\e[7m"
|
|
|
|
# else
|
|
|
|
# print "\e[0m"
|
|
|
|
# end
|