Newbie question by apparent old guy;)

L

len

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

Len Sumnler
(Old Programmer)
 
B

Brian Schröder

I was trying some code from the "Learning to Program" by Chris Pine,
excellent site by the way for learning Ruby.
=20
The code I tried was;
=20
puts Time.mktime(1952, 4, 3)
=20
I get an error;
=20
Argument Error: argument out of range
=20
Don't tell me Ruby practices age discrimination:{o
=20
Len Sumnler
(Old Programmer)
=20
=20
=20

Works for me:

$ ruby -ve 'puts Time.mktime(1952, 4, 3)'
ruby 1.8.3 (2005-06-23) [i486-linux]
Thu Apr 03 00:00:00 CET 1952

regards,

Brian

--=20
http://ruby.brian-schroeder.de/

Stringed instrument chords: http://chordlist.brian-schroeder.de/
 
T

Timothy Hunter

len said:
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

Len Sumnler
(Old Programmer)

Interesting. Which version of Ruby are you using? It works for me at 1.8.2:

test$ irb
irb(main):001:0> puts Time.mktime(1952, 4, 3)
Thu Apr 03 00:00:00 EST 1952
=> nil


Tim Hunter
(Another Old Programmer)
 
N

nobu.nokada

Hi,

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.
 
K

Kevin Olbrich

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.=20

_Kevin

-----Original Message-----
From: len [mailto:[email protected]]=20
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

Len Sumnler
(Old Programmer)
 
K

Kero

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

+--- Kero ------------------------- kero@chello@nl ---+
| all the meaningless and empty words I spoke |
| Promises -- The Cranberries |
+--- M38c --- http://members.chello.nl/k.vangelder ---+
 
K

Kevin Olbrich

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:[email protected]]
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

+--- Kero ------------------------- kero@chello@nl ---+
| all the meaningless and empty words I spoke |
| Promises -- The Cranberries |
+--- M38c --- http://members.chello.nl/k.vangelder ---+
 
L

len

I am using the latest version of Ruby 1.8.2 on a Windows XP
Professional so I will assume that it is a problem with platform.

However, now I feel really old knowing I was born before the "epoch" :)

Len Sumnler
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,498
Latest member
log5Sshell/alfa5

Latest Threads

Top