Index: tests/regressiontests/forms/localflavor/pl.py
===================================================================
--- tests/regressiontests/forms/localflavor/pl.py	(revision 7422)
+++ tests/regressiontests/forms/localflavor/pl.py	(working copy)
@@ -47,9 +47,24 @@
 # PLNationalIdentificationNumberField ############################################
 
 >>> from django.contrib.localflavor.pl.forms import PLNationalIdentificationNumberField
+>>> f =  PLNationalIdentificationNumberField(birthday_check = False)
+>>> f.clean('20220412160')
+u'20220412160'
+>>> f.gender
+'F'
 >>> f =  PLNationalIdentificationNumberField()
 >>> f.clean('80071610614')
 u'80071610614'
+>>> f.gender
+'M'
+>>> f.birthday
+datetime.date(1980, 7, 16)
+>>> f.clean('84070712131')
+u'84070712131'
+>>> f.gender
+'M'
+>>> f.birthday
+datetime.date(1984, 7, 7)
 >>> f.clean('80071610610')
 Traceback (most recent call last):
 ...
@@ -62,6 +77,14 @@
 Traceback (most recent call last):
 ...
 ValidationError: [u'National Identification Number consists of 11 digits.']
+>>> f.clean('20220412153')
+Traceback (most recent call last):
+...
+ValidationError: [u'Invalid National Identification Number (birthdate from the future).']
+>>> f.clean('20333412154')
+Traceback (most recent call last):
+...
+ValidationError: [u'Invalid National Identification Number (birthdate is not valid).']
 
 # PLNationalBusinessRegisterField ################################################
 
Index: django/contrib/localflavor/pl/forms.py
===================================================================
--- django/contrib/localflavor/pl/forms.py	(revision 7422)
+++ django/contrib/localflavor/pl/forms.py	(working copy)
@@ -2,6 +2,7 @@
 Polish-specific form helpers
 """
 
+from datetime import date
 import re
 
 from django.newforms import ValidationError
@@ -32,22 +33,48 @@
     Checks the following rules:
         * the length consist of 11 digits
         * has a valid checksum
+        * birthday is valid
+        * birthday is from the past
 
+    Calculates additional attributes for provided PESEL number:
+        * self.gender ('F' or 'M'),
+        * self.birthday (datetime.date) - if self.birthday_check is True.
+
     The algorithm is documented at http://en.wikipedia.org/wiki/PESEL.
     """
     default_error_messages = {
         'invalid': _(u'National Identification Number consists of 11 digits.'),
         'checksum': _(u'Wrong checksum for the National Identification Number.'),
+        'invalid-birthday': _(u'Invalid National Identification Number (birthdate is not valid).'),
+        'future-birthday': _(u'Invalid National Identification Number (birthdate from the future).'),
     }
 
-    def __init__(self, *args, **kwargs):
+    def __init__(self, birthday_check = True, *args, **kwargs):
         super(PLNationalIdentificationNumberField, self).__init__(r'^\d{11}$',
             max_length=None, min_length=None, *args, **kwargs)
+        self.birthday_check = birthday_check
 
     def clean(self,value):
         super(PLNationalIdentificationNumberField, self).clean(value)
         if not self.has_valid_checksum(value):
             raise ValidationError(self.error_messages['checksum'])
+
+        if int(value[9]) % 2:
+            self.gender = 'M'
+        else:
+            self.gender = 'F'
+
+        if self.birthday_check:
+            day = int(value[4:6])
+            offset, month = divmod(int(value[2:4]), 20)
+            year = 1900 + int(value[0:2]) + 100 * ((offset + 1) % 5 - 1)
+            try:
+                self.birthday = date(year, month, day)
+            except ValueError:
+                raise ValidationError(self.error_messages['invalid-birthday'])
+            if self.birthday > date.today():
+                raise ValidationError(self.error_messages['future-birthday'])
+
         return u'%s' % value
 
     def has_valid_checksum(self, number):
Index: django/conf/locale/pl/LC_MESSAGES/django.po
===================================================================
--- django/conf/locale/pl/LC_MESSAGES/django.po	(revision 7422)
+++ django/conf/locale/pl/LC_MESSAGES/django.po	(working copy)
@@ -5,7 +5,7 @@
 msgstr ""
 "Project-Id-Version: Django\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-04-14 18:02+0200\n"
+"POT-Creation-Date: 2008-04-15 04:15+0200\n"
 "PO-Revision-Date: 2008-02-25 15:53+0100\n"
 "Last-Translator: Piotr Lewandowski <django@icomputing.pl>\n"
 "Language-Team: Polish <pl@li.org>\n"
@@ -2707,32 +2707,40 @@
 msgid "This field requires 11 digits."
 msgstr "To pole musi zawierać 11 cyfr."
 
-#: contrib/localflavor/pl/forms.py:39
+#: contrib/localflavor/pl/forms.py:46
 msgid "National Identification Number consists of 11 digits."
 msgstr "Numer PESEL składa się z 11 cyfr."
 
-#: contrib/localflavor/pl/forms.py:40
+#: contrib/localflavor/pl/forms.py:47
 msgid "Wrong checksum for the National Identification Number."
 msgstr "Błędna suma kontrolna numeru PESEL."
 
-#: contrib/localflavor/pl/forms.py:72
+#: contrib/localflavor/pl/forms.py:48
+msgid "Invalid National Identification Number (birthdate is not valid)."
+msgstr "Nieprawidłowy numer PESEL (data urodzin nie jest prawidłowa)."
+
+#: contrib/localflavor/pl/forms.py:49
+msgid "Invalid National Identification Number (birthdate from the future)."
+msgstr "Nieprawidłowy Numer PESEL (przyszła data urodzin)."
+
+#: contrib/localflavor/pl/forms.py:99
 msgid ""
 "Enter a tax number field (NIP) in the format XXX-XXX-XX-XX or XX-XX-XXX-XXX."
 msgstr "Wpisz numer NIP w formacie XXX-XXX-XX-XX or XX-XX-XXX-XXX."
 
-#: contrib/localflavor/pl/forms.py:73
+#: contrib/localflavor/pl/forms.py:100
 msgid "Wrong checksum for the Tax Number (NIP)."
 msgstr "Błędna suma kontrolna numeru NIP"
 
-#: contrib/localflavor/pl/forms.py:112
+#: contrib/localflavor/pl/forms.py:139
 msgid "National Business Register Number (REGON) consists of 7 or 9 digits."
 msgstr "Numer REGON składa się z 7 lub 9 cyfr."
 
-#: contrib/localflavor/pl/forms.py:113
+#: contrib/localflavor/pl/forms.py:140
 msgid "Wrong checksum for the National Business Register Number (REGON)."
 msgstr "Błędna suma kontrolna numeru REGON"
 
-#: contrib/localflavor/pl/forms.py:156
+#: contrib/localflavor/pl/forms.py:183
 msgid "Enter a postal code in the format XX-XXX."
 msgstr "Wpisz kod pocztowy w formacie XX-XXX."
 
