At Sun, 14 Aug 2005 23:11:13 +0900,
len wrote in [ruby-talk:152119]:
The code I tried was;
puts Time.mktime(1952, 4, 3)
I get an error;
Argument Error: argument out of range
Time class is just a wrapper of time_t. That error occurs if
time_t can't represent dates before the epoch of time_t, that
is, time_t is unsigned on your platform.
The "Time" class stores its value as a unix timestamp, which is defined as
the number of seconds since Jan 1, 1970. Dates earlier than that won't work.
Try using "Date" or "DateTime" instead.
_Kevin
···
-----Original Message-----
From: len [mailto:lsumnler@gmail.com]
Sent: Sunday, August 14, 2005 10:11 AM
To: ruby-talk ML
Subject: Newbie question by apparent old guy;)
I was trying some code from the "Learning to Program" by Chris Pine,
excellent site by the way for learning Ruby.
The code I tried was;
puts Time.mktime(1952, 4, 3)
I get an error;
Argument Error: argument out of range
Don't tell me Ruby practices age discrimination:{o
The "Time" class stores its value as a unix timestamp, which is defined as
the number of seconds since Jan 1, 1970. Dates earlier than that won't work.
Try using "Date" or "DateTime" instead.
What I found in some of my code:
# Ruby 1.6 accepts only Time after 1970, Jan 1 (UTC)
# Ruby 1.7 accepts Time before that
and if I try (debian has 1.6 and 1.8 coexisting) that is confirmed:
$ ruby1.6 -e 'p Time.local(1952)'
-e:1:in `local': argument out of range (ArgumentError)
from -e:1
$ ruby1.8 -e 'p Time.local(1952)'
Tue Jan 01 00:00:00 CET 1952
This is apparently inconsistent across platforms because if I do
'p Time.local(1952)' on my windows machine (ruby 1.8.2) I get an out of
range error.
_Kevin
···
-----Original Message-----
From: Kero [mailto:kero@chello.single-dot.nl]
Sent: Sunday, August 14, 2005 10:36 AM
To: ruby-talk ML
Subject: Re: Newbie question by apparent old guy;)
The "Time" class stores its value as a unix timestamp, which is
defined as the number of seconds since Jan 1, 1970. Dates earlier than
that won't work.
Try using "Date" or "DateTime" instead.
What I found in some of my code:
# Ruby 1.6 accepts only Time after 1970, Jan 1 (UTC)
# Ruby 1.7 accepts Time before that
and if I try (debian has 1.6 and 1.8 coexisting) that is confirmed:
$ ruby1.6 -e 'p Time.local(1952)'
-e:1:in `local': argument out of range (ArgumentError)
from -e:1
$ ruby1.8 -e 'p Time.local(1952)'
Tue Jan 01 00:00:00 CET 1952