2
在我的rails項目中,我只希望在一天之內獲得Date
實例。年和月使用當前值。如何在一天之內創建新的日期實例
我可以寫這樣的:
day = 3
date = Date.new(Date.current.year, Date.current.month, day)
和
date = Date.current.beginning_of_month + (day - 1).days
你會如何寫函數這樣嗎? 有更好的實現嗎?