moov-io / metro2

Open Source Metro 2 consumer credit history report for credit report file creation and validation
https://moov-io.github.io/metro2/
Apache License 2.0
98 stars 46 forks source link

JSON conversion for not available date fields is “0001-01-01T00:00:00Z" #196

Open caryp opened 5 months ago

caryp commented 5 months ago

Metro2 Version: latest|0.9.0

What were you trying to do? Convert a METRO2 file to JSON with zero-filled dates for some non-required date fields.

What did you expect to see? From the CDIA's METRO2 2020 Credit Reporting Resource Guide, we see that the Header Record (Char format) Field 10 is Program Date, is not required, and is Recording Technique of "numeric".

From the "Programing standards" section in the same guide it mentions: "If a numeric field is not available, it should be zero filled."

I would expect the converted JSON data for a zero-filled date field to be blank (e.g. "")

What did you see? Zero-filled dates are being converted to JSON with a value of “0001-01-01T00:00:00Z" -- which is the IsZero() value.

How can we reproduce the problem? Convert any non-required data field (like Base Record Field 10 "dateClosed") to all zeros and convert to JSON.

caryp commented 5 months ago

Not sure how to assign to myself, but I am happy to submit a proposed change for this.

caryp commented 5 months ago

@adamdecaf what do you think about this change?

adamdecaf commented 5 months ago

Is this true for every usage of Time? Or just that one field?

caryp commented 5 months ago

This applies to all date fields that are not required. There are some date fields that are required though -- for example: Header Field 8 "Activity Date" is required. Perhaps that would be another improvement to fail if required date fields IsZero() is true?

adamdecaf commented 5 months ago

I would like to error if required fields aren't set, but that could be done in Validate() rather than during formatting.