arthurdejong / python-stdnum

A Python library to provide functions to handle, parse and validate standard numbers.
https://arthurdejong.org/python-stdnum/
GNU Lesser General Public License v2.1
495 stars 205 forks source link

gs1_128: add support for date parsing without day #294

Closed alexis-via closed 2 years ago

alexis-via commented 2 years ago

Date such as '(17)260400' is now properly interpreted as April 30th 2026. Previous behavior: crash.

Information source : GS1 General specifications https://www.gs1.org/docs/barcodes/GS1_General_Specifications.pdf section "Expiration date: AI (17)" page 162

When it is not necessary to specify the day (the day field is filled with two zeroes), the
resultant data string SHALL be interpreted as the last day of the noted month including any
adjustment for leap years (e.g., “130200” is “2013 February 28”, “160200” is “2016 February
29”, etc.).
pokoli commented 2 years ago

It is needed that the encode uses such format or this is an optional value?

I see your tests are failing because the dateutil library is not available. Could you please fix that?

alexis-via commented 2 years ago

Tests are now green. I removed the dependency on dateutil.

arthurdejong commented 2 years ago

@alexis-via thanks for providing this change and tanks @pokoli for providing some feedback!

Merged as 7d81eac.