ruby - 根据年-月来获取每个月份第一天和最后一天

访问量: 538

参考: https://stackoverflow.com/a/43892850

year = 2017
month = 5
require 'date'
Date.new(year, month, 1)  #=> #<Date: 2017-05-01 ...>
Date.new(year, month, -1) #=> #<Date: 2017-05-31 ...>

订阅/RSS Feed

Subscribe

分类/category