Bugs: Browse | Submit New | Admin

[#10083] Inconsistencies between Time and Date classes

Date:
2007-04-13 10:06
Priority:
3
Submitted By:
Jan Faber (fjan)
Assigned To:
Yukihiro Matsumoto (matz)
Category:
Misc / Other Standard Library
State:
Open
Platform:
 
Summary:
Inconsistencies between Time and Date classes

Detailed description
The Time and Date class treat edge cases differently. This is prone to introduce errors since they are often used
together.

Example 1: 24:00 is valid in DateTime but not in Time
puts DateTime::valid_time?(24,0,0) # => 1 (valid)
puts Time.utc(2007,1,1,24,0) # => Argument error: argument out of range

Example 2: 31st of april wraps around in Time but is an error in Date
puts Time.parse("4/31/2007") # => Tue May 1 00:00:00 2007
puts DateTime.parse("4/31/2007") # => Argument error: invalid date

Especially the first one is annoying because you need to check for "hour==24" everywhere you parse a human
entered string into a since otherwise it will parse and validate fine but then error out when you try to make a time
out of it. (Try out entering 24:00 as a time in a random RoR application and see it crash :-/)

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-06-14 13:46
Sender: Shyouhei Urabe

Assigning to matz: [ruby-core:10926]

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
assigned_toshyouhei2007-06-14 13:46shyouhei
assigned_tonone2007-06-12 02:25zenspider