ruby - How can I create a new Date with just a weekday number? -


I use the day of the day to date. I am using Wday, but then how can I create a new date with that number (without using Date.commercial)? I only need the next week's date. For example, if I have 2 (Tuesday) then the new date will be the next Tuesday date (2009-07-28). Thanks!

You can convert a number of days (like 2 ) to one The name of the day is as follows:

  day_number = 2 date :: DAYNAMES [day_number] # = & gt; 'Tuesday'  

If you install gem, you can parsing the natural language of dates and times. For example:

  chronic Parse 'Next Tuesday' # It is currently Thursday, July 23rd, # = & gt; By adding them, you can  
  require the 'old' class MyClass # next week gives a date for the ninth day of the week next_n_de (n) chronic. From ("next # {Date: DAYNAMES [n}} ") End End  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -