From 73b4de1e330837fbf09b909a3d568513ab5b3fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Nadolski?= Date: Wed, 17 Aug 2022 08:36:16 +0200 Subject: [PATCH] Fix year format Pad least significant digits in a year with zero. Fixes case when year < 10 (e.g. year == 0 would have produced new_y 190 and 200 instead of 1900 and 2000) --- personnummer/personnummer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/personnummer/personnummer.py b/personnummer/personnummer.py index 2224db2..69628f6 100644 --- a/personnummer/personnummer.py +++ b/personnummer/personnummer.py @@ -211,7 +211,7 @@ def test_date(year, month, day): Test if the input parameters are a valid date or not """ for x in ['19', '20']: - new_y = x.__str__() + year.__str__() + new_y = x.__str__() + year.__str__().zfill(2) new_y = int(new_y) try: date = datetime.date(new_y, month, day)