3/4ハリボテ
This commit is contained in:
parent
92e3050f67
commit
aa4394f2d6
1 changed files with 24 additions and 27 deletions
51
cal.rb
Normal file → Executable file
51
cal.rb
Normal file → Executable file
|
@ -1,32 +1,29 @@
|
||||||
|
#!/usr/bin/ruby
|
||||||
|
|
||||||
require 'date'
|
require 'date'
|
||||||
|
require 'optparse'
|
||||||
|
|
||||||
time = Time.now.localtime
|
optmonth = ARGV.getopts('m:')
|
||||||
year = time.year.to_i
|
optyear = ARGV.getopts('y:')
|
||||||
month = time.month.to_i
|
|
||||||
currentday = time.day # 現在日
|
|
||||||
startwday = Date.new(year,month,1).wday # その月の最初の曜日
|
|
||||||
endmonth = Date.new(year,month,-1) # その月の日数
|
|
||||||
endwday = time.wday # その月の最後の曜日
|
|
||||||
|
|
||||||
|
# opt = OptionParser.new
|
||||||
|
# opt.on('-m')
|
||||||
|
# opt.on('-y')
|
||||||
|
# opt.parse!
|
||||||
|
|
||||||
a = Date.new(2024, 3, 6)
|
year = Date.today.year
|
||||||
puts "\t#{a.month}月\s#{a.year}"
|
month = Date.today.month
|
||||||
b = %w(日 月 火 水 木 金 土)
|
startwday = Date.new(year, month, 1).wday # その月の最初の曜日
|
||||||
b.each do |week|
|
enddate = Date.new(year, month, -1).day # その月の最後の曜日
|
||||||
print "\s#{week}"
|
week = %w[日 月 火 水 木 金 土]
|
||||||
|
|
||||||
|
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
|
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
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue