Created
January 20, 2012 15:37
-
-
Save miyohide/1647914 to your computer and use it in GitHub Desktop.
特定基準日の開始日を求める
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support' | |
require 'active_support/core_ext' | |
def my_start_of_month(today, base) | |
today.prev_month.change(:day => base) | |
end | |
my_start_of_month(Date.today, 28) # => 2012年1月21日に実行した場合、 Wed, 28 Dec 2011 が返る |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment