# New Ticket Created by  Zefram 
# Please include the string:  [perl #127008]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=127008 >


The documentation for Date.new says that when given a string input the
string is to be in ISO 8601 format.  In fact it accepts many kinds of
non ISO 8601 strings:

    "1-01-01"            (too few year digits)
    "2000-1-1"           (too few month and day digits)
    "2000-  01-01"       (illegal spaces)
    "-01-01"             (no year digits)
    "2000-0\x[666]-01"   (non-ASCII digit)
    "2000.5-01-01"       (illegal fraction)
    "2000-001-001"       (too many month and day digits)
    "2000-+01-+01"       (sign on month and day)

The documentation doesn't actually say that an exception will be thrown
when it is given an invalid string input, but it doesn't give any clue
as to how non ISO 8601 input would be parsed.  Some regexp-based syntax
checking would be welcome here.

Bearing in mind your response to [perl #127002], perhaps you intend to
accept some strings that are not in ISO 8601 format, but the range that
is accepted here goes beyond "liberal in what you accept".  Many of these
strings are quite some distance away from being ISO 8601.  Whatever you
intend to accept, it would also be wise to document explicitly what
happens with non ISO 8601 input.

-zefram

Reply via email to