This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
Handling Commercial Dates | ||
---|---|---|
Code | Expected | Actual |
require 'date' sunday = DateTime.new(2006, 1, 1) sunday.year |
2006 | 2006 |
sunday.cwyear |
2005 | 2005 |
sunday.cweek |
52 | 52 |
sunday.wday |
0 | 0 |
sunday.cwday |
7 | 7 |
monday = sunday + 1 monday.cwyear |
2006 | 2006 |
monday.cweek |
1 | 1 |
(sunday...sunday+7).each do |d| puts "#{d.strftime("%a")} #{d.wday} #{d.cwday}" end |
Sun 0 7 Mon 1 1 Tue 2 2 Wed 3 3 Thu 4 4 Fri 5 5 Sat 6 6 |
Sun 0 7 Mon 1 1 Tue 2 2 Wed 3 3 Thu 4 4 Fri 5 5 Sat 6 6 |