Date format in JSON output is hard coded to %d/%m/%Y
https://github.com/invoice-x/invoice2data/blob/48006efe961584660414c432afbad1ef05a65b3c/src/invoice2data/output/to_json.py#L42
Date format is hard coded to french (maybe more) format day/month/year.
Could we add an options like date_formats_output or something to have a way to produce more standard format like %Y-%m-%d ?
I also noticed that only date field is handled, but we ignore fields prefixed with date to apply strftime on them
Totally agree. Just do a PR to change it.
@m3nu OK, I'm not familiar with Python yet but I'm on it ;)
Please just tell me if this approach looks fine to you :
def write_to_file(data, path, date_output_format='%d/%m/%Y'):
As we have path arg, I would add a new arg date_output_format in each write_to_file functions and pass it in call of output_module.write_to_file() from main.py
Yeah. Could be good to add it as optional keyword argument. You want to keep the old default or make it an ISO format?
One small style note: When a string is for formatting, one would usually use double quotes. "%d-.."
OK for double quoting ! Maybe we should keep previous format as default and override on demand to avoid BC ?
Yes. Let's keep the old format.
I'm almost good with code and test, but I introduced a change... You could call it a Breaking Change or a Bug Fix, you decide ;)
If we consider output JSON of free_fiber.pdf file, we had :
{
"date": "02/07/2015",
"date_due": "2015-07-05 00:00:00"
}
Now, we have this output (without --output-date-format option) :
{
"date": "02/07/2015",
"date_due": "05/07/2015"
}
And (with --output-date-format %Y-%m-%d)
{
"date": "2015-07-02",
"date_due": "2015-07-05"
}
It sounds better to me because we have only one format for dates. PR coming soon...
Last option looks best, I think. I'll write a note about it in the release log. Better to fix this now then wait even longer.
I assume most people use it as library anyways, so they get a direct datetime object.
Fixed by 212