Project

General

Profile

Actions

Bug #11984

closed

DateTime.parse can parse invalid datetime string

Added by lanscene (jarry xu) almost 9 years ago. Updated over 5 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux] and ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
[ruby-core:72837]

Description

It seems if you pass a string which begins with 2 alphabets and following is 7 numerics, it can be parsed as DateTime, as follows

irb(main):002:0> require 'time'
irb(main):008:0> dt0 = DateTime.parse('fg4534253dd')
=> #<DateTime: 4534-09-10T00:00:00+00:00 ((3377322j,0s,0n),+0s,2299161j)>
irb(main):009:0> dt0 = DateTime.parse('fg4534253')
=> #<DateTime: 4534-09-10T00:00:00+00:00 ((3377322j,0s,0n),+0s,2299161j)>
irb(main):010:0> DateTime.parse('gg1233234')
=> #<DateTime: 1233-08-22T00:00:00+00:00 ((2171645j,0s,0n),+0s,2299161j)>
irb(main):011:0> DateTime.parse('gg1233234dd')
=> #<DateTime: 1233-08-22T00:00:00+00:00 ((2171645j,0s,0n),+0s,2299161j)>

Actions

Also available in: Atom PDF

Like0
Like0Like0