Is this a bug in Time.local?

R

Richard A. Ryan

Hi,

I've tried this for ruby 1.8.1 and 1.6.8.

irb(main):001:0> Time.local(30, 15, 11, nil, nil, 2004, nil, 203, nil, nil)
=> Thu Jan 01 11:15:30 GMT 2004

For the 203rd day of the year, it does not seem I should be getting Jan 1.
Is this a bug?

Thank you,
Richard Ryan
 
R

Richard A. Ryan

Hi,

Thanks for the reply. If the consistency of the treatment of yday
with mktime means it's not a bug, then why wouldn't the inconsistency
with mktime's autonormalization feature be a bug? And if Time.local
and Time.gmtime are to differ with the operation of mktime and gmtime,
why not differ on the side of convenience?

Thairr eess no porrpooss to theess...

Thanks again,
R
 
R

Richard A. Ryan

Hi,
Actually, I think that the 10-argument form of Time.local/mktime is deprecated.
You should really be using the 1-to-8 argument forms, which have no wday or
yday fields at all:

Time.mktime(year[, month[, day[, hour[, min[, sec[, msec[, zone]]]]]]])

The reason why I was trying to do it the way I was doing it was because the
data I was looking at had the day of the year and not the day of the month.
I really would be using this if I had the day of the month readily
available---the question wouldn't even have come up in the first place if it
weren't for that. I've used the `date' library together with Time as a
workaround, but it's not the way I would prefer to do it.

R
 

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,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top