We have a requirement for a "Partial Date" object which would allow you to specify dates such as
new PartialDate(1, null, null); // first of the month
new PartialDate(1, 2, null); // first of the February
new PartialDate(null, 2, null); // February
The use case is in relation to events. For example, you might have a course which takes place every January, in which case you don't want or need to specify the year component of the date object.
We need to be able to sort by these dates based around some arbitrary rules, hence my thought to implement a data type (which will implement IComparable<PartialDate>
, however this is outside the scope of my question).
I have a couple of Questions:
- Is this a bad idea?
- I'm working in .NET, Is there some part of the framework (or 3rd party library) which will provide this functionality?