Skip to content

LocalDate constructor validation not working #801

@jkonecki

Description

@jkonecki

I've noticed a bug in NodaTime 2.0 LocalDate constructor - parameter validation doesn't seem to be working. It was working as expected in version 1.3.

Example:

var date = new LocalDate(2001, 1, -1);

Expected result:
An ArgumentOutOfRangeException should be thrown as described in documentation:

<exception cref="ArgumentOutOfRangeException">The parameters do not form a valid date.</exception>

Actual result:

A LocalDate instance is created and can be used:

            var date = new LocalDate(2001, 1, -1);
            var year = date.Year; // value: 0
            var month = date.Month; // value: 32
            var day = date.Day;  // value: 63

An ArgumentOutOfRangeException is thrown from ToString() method.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions