FamilySearch/gedcomx-csharp

DateInfo to GedcomxDate?

Opened this issue · 3 comments

Hi,

There should be a unified way to extract an object-oriented date value for ordering purposes from a DateInfo class.

I'd say you should add Day, Month, and Year properties to the DateInfo class, that will return the year parsed out from the date (maybe via regex). Actually having these properties as read-write would be very nice too.
I think the DateInfo lacks some manipulation functionality such as dealing with partial dates, as well as conversion to and from .NET DateTime when possible.

UPDATE,
And the truth is that it's all in the GedcomxDate library, there is just no connection between the two.

@weitzhandler Please feel free to contribute to this project. We accept pull requests :-).

The library itself looks pretty extensive. I just can't seem to find a connection between DateInfo and GedcomxDate, why isn't there a property on the DateInfo class that returns the date (or date-time) as a GedcomxDate?

You can use
dateInfo.SetFormal(gedcomxDate.FormalString());
in one direction, or
gedcomxDate = GedcomxDateUtil.Parse(dateInfo.Formal);
in the other direction.

Feel free to add convinience methods. I personally prefer not to have additional project dependency.