lists.arthurdejong.org
RSS feed

python-stdnum branch master updated. 1.20-26-g852515c

[Date Prev][Date Next] [Thread Prev][Thread Next]

python-stdnum branch master updated. 1.20-26-g852515c



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "python-stdnum".

The branch, master has been updated
       via  852515c92c97739df1a16ffe3ddac91c9cf03e38 (commit)
      from  fc766bc3869bc100516431eebb3aa5e2a19da1a1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/python-stdnum/commit/?id=852515c92c97739df1a16ffe3ddac91c9cf03e38

commit 852515c92c97739df1a16ffe3ddac91c9cf03e38
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Thu Mar 27 13:40:07 2025 +0100

    Fix Czech Rodné číslo check digit validation
    
    It seems that a small minority of numbers assigned with a checksum of 10
    are still valid and expected to have a check digit value of 0. According
    to https://www.domzo13.cz/sw/evok/help/born_numbers.html this practice
    even happended (but less frequently) after 1985.
    
    Closes https://github.com/arthurdejong/python-stdnum/issues/468

diff --git a/stdnum/cz/rc.py b/stdnum/cz/rc.py
index 627c312..79911c3 100644
--- a/stdnum/cz/rc.py
+++ b/stdnum/cz/rc.py
@@ -1,7 +1,7 @@
 # rc.py - functions for handling Czech birth numbers
 # coding: utf-8
 #
-# Copyright (C) 2012-2019 Arthur de Jong
+# Copyright (C) 2012-2025 Arthur de Jong
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -90,14 +90,10 @@ def validate(number):
     if len(number) not in (9, 10):
         raise InvalidLength()
     # check if birth date is valid
-    birth_date = get_birth_date(number)
-    # TODO: check that the birth date is not in the future
+    get_birth_date(number)
     # check the check digit (10 digit numbers only)
     if len(number) == 10:
-        check = int(number[:-1]) % 11
-        # before 1985 the checksum could be 0 or 10
-        if birth_date < datetime.date(1985, 1, 1):
-            check = check % 10
+        check = int(number[:-1]) % 11 % 10
         if number[-1] != str(check):
             raise InvalidChecksum()
     return number
diff --git a/tests/test_cz_rc.doctest b/tests/test_cz_rc.doctest
new file mode 100644
index 0000000..0a83eeb
--- /dev/null
+++ b/tests/test_cz_rc.doctest
@@ -0,0 +1,36 @@
+test_cz_rc.doctest - more detailed doctests for stdnum.cz.rc
+
+Copyright (C) 2025 Arthur de Jong
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA
+
+
+This file contains more detailed doctests for the stdnum.cz.rc
+module.
+
+>>> from stdnum.cz import rc
+
+
+
+These have been found online and should all be valid numbers.
+
+>>> numbers = '''
+...
+... 8801251680
+...
+... '''
+>>> [x for x in numbers.splitlines() if x and not rc.is_valid(x)]
+[]

-----------------------------------------------------------------------

Summary of changes:
 stdnum/cz/rc.py                                  | 10 +++-------
 tests/{test_pt_cc.doctest => test_cz_rc.doctest} | 18 ++++++++----------
 2 files changed, 11 insertions(+), 17 deletions(-)
 copy tests/{test_pt_cc.doctest => test_cz_rc.doctest} (65%)


hooks/post-receive
-- 
python-stdnum