www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18552] New: std.datetime.date.Date strips year int argument

https://issues.dlang.org/show_bug.cgi?id=18552

          Issue ID: 18552
           Summary: std.datetime.date.Date strips year int argument to
                    short
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: feklushkin.denis gmail.com

std.datetime.date.Date accepts int year as argument but silently strips it to
short:

    this(int year, int month, int day)  safe pure
    {
        enforceValid!"months"(cast(Month) month);
        enforceValid!"days"(year, cast(Month) month, day);

        _year  = cast(short) year;
        _month = cast(Month) month;
        _day   = cast(ubyte) day;
    }

It is need to add bounds check or change argument type.

--
Mar 03 2018