Ruby gets a specified number of month dates _ruby topics

Source: Internet
Author: User

The code is as follows:

Copy Code code as follows:

Require ' date '

Day = Date.new (2008, 2,-1)
End_of_month = Day.strftime ('%d '). to_i
Year_and_month = Day.strftime ('%y%m ')
For today in 1..end_of_month do
P sprintf ('%s%02d ', Year_and_month, today)
End

Other references:
http://d.hatena.ne.jp/littlebuddha/20081023/1224744392
Http://blog.ozacc.com/archives/001492.html
Http://www.ftnk.jp/~fumi/cl/2005-10-14-6.html
Http://www.namaraii.com/rubytips/?%C6%FC%C9%D5%A4%C8%BB%FE%B9%EF

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.