fjord/cal.rb

30 lines
607 B
Ruby
Raw Normal View History

2024-03-07 22:40:32 +09:00
#!/usr/bin/ruby
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
optmonth = ARGV.getopts('m:')
optyear = ARGV.getopts('y:')
2024-03-06 22:31:13 +09:00
2024-03-07 22:40:32 +09:00
# opt = OptionParser.new
# opt.on('-m')
# opt.on('-y')
# opt.parse!
2024-03-06 22:31:13 +09:00
2024-03-07 22:40:32 +09:00
year = Date.today.year
month = Date.today.month
startwday = Date.new(year, month, 1).wday # その月の最初の曜日
enddate = Date.new(year, month, -1).day # その月の最後の曜日
week = %w[日 月 火 水 木 金 土]
2024-03-06 22:31:13 +09:00
2024-03-07 22:40:32 +09:00
puts "\t#{month}#{year}"
puts week.join(' ')
print ' ' * startwday
days = startwday
(1..enddate).each do |day|
print day.to_s.rjust(2) + ' '
days += 1
print "\n" if days % 7 == 0
end