Skip to content

Instantly share code, notes, and snippets.

@miyohide
Created January 20, 2012 15:37
Show Gist options
  • Save miyohide/1647914 to your computer and use it in GitHub Desktop.
Save miyohide/1647914 to your computer and use it in GitHub Desktop.
特定基準日の開始日を求める
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