Skip to content

Commit e4080f9

Browse files
committed
Add support for Finland HETU new century indicating signs
1 parent 6d366e3 commit e4080f9

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

stdnum/fi/hetu.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,15 @@
5050

5151
_century_codes = {
5252
'+': 1800,
53-
'-': 1900,
54-
'A': 2000,
53+
**dict.fromkeys(('-', 'Y', 'X', 'W', 'V', 'U'), 1900),
54+
**dict.fromkeys(('A', 'B', 'C', 'D', 'E', 'F'), 2000),
5555
}
5656

5757
# Finnish personal identity codes are composed of date part, century
5858
# indicating sign, individual number and control character.
5959
# ddmmyyciiiC
6060
_hetu_re = re.compile(r'^(?P<day>[0123]\d)(?P<month>[01]\d)(?P<year>\d\d)'
61-
r'(?P<century>[-+A])(?P<individual>\d\d\d)'
61+
r'(?P<century>[-+ABCDEFYXWVU])(?P<individual>\d\d\d)'
6262
r'(?P<control>[0-9ABCDEFHJKLMNPRSTUVWXY])$')
6363

6464

tests/test_fi_hetu.doctest

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ Normal values that should just work.
3939
>>> hetu.validate('131052a308t')
4040
'131052A308T'
4141

42+
From the beginning of year 2023, additional century indicating signs were added.
43+
This doesn't affect the checksum calculation.
44+
45+
>>> hetu.validate('131052B308T')
46+
'131052B308T'
47+
48+
>>> hetu.validate('131052X308T')
49+
'131052X308T'
4250

4351
Invalid checksum:
4452

0 commit comments

Comments
 (0)