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.

Date and Time
CodeExpectedActual
Time.now
Sat Mar 18 14:49:30 EST 2006 Fri Apr 14 17:24:44 EDT 2006
Time.at(0)
Wed Dec 31 19:00:00 EST 1969 Wed Dec 31 19:00:00 EST 1969
t = Time.at(0)
t.sec
0 0
t.min
0 0
t.hour
19 19
t.day
31 31
t.month
12 12
t.year
1969 1969
t.wday
3 3
t.yday
365 365
t.isdst
false false
t.zone
"EST" "EST"
Time.local(1865, 4, 9)
ArgumentError: time out of range
...
ArgumentError: time out of range
	from (irb):14:in `local'
	from (irb):14
Time.local(2100, 1, 1)
ArgumentError: time out of range
...
ArgumentError: time out of range
	from (irb):15:in `local'
	from (irb):15
require 'date'
DateTime::new(1865, 4, 9).to_s
"1865-04-09T00:00:00Z" "1865-04-09T00:00:00Z"
DateTime::new(2100, 1, 1).to_s
"2100-01-01T00:00:00Z" "2100-01-01T00:00:00Z"
DateTime::new.to_s
"-4712-01-01T00:00:00Z" "-4712-01-01T00:00:00Z"
DateTime::now.to_s
"2006-03-18T14:53:18-0500" "2006-04-14T17:24:44-0400"
Time.local(1865,4,9)
Sun Apr 09 00:00:00 EWT 1865
Error! (Exception?) Here's stdout:
ArgumentError: time out of range
	from (irb):21:in `local'
	from (irb):21
Time.local(2100,1,1)
Fri Jan 01 00:00:00 EST 2100
Error! (Exception?) Here's stdout:
ArgumentError: time out of range
	from (irb):22:in `local'
	from (irb):22