Section 7.10. Validating a DateTime

7.9. Finding the Day of the Year

The day number within the year is sometimes called the Julian date, which is not directly related to the Julian calendar, which has gone out of style. Other people insist that this usage is not correct, so we won't use it from here on.

No matter what you call it, there will be times you want to know what day of the year it is, from 1 to 366. This is easy in Ruby; we use the yday method:

t = day = t.yday      # 315

The Ruby Way(c) Solutions and Techniques in Ruby Programming
The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition)
ISBN: 0672328844
EAN: 2147483647
Year: 2004
Pages: 269
Authors: Hal Fulton

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: