prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Latvian ssn generator is not correct
  * Faker version: 17.0.0
  * OS: Windows
  
  
  Latvian ssn generator generates ssn in format 'ddd-dd-dddd', which is not correct. 
  
  ### Steps to reproduce
  
  ```
  from faker import Faker
  fake = Faker('lv_LV')
  fake.ssn()
  
  ```
  
  ### Expected behavior
  
  It should be 12 characters long DDMMYY-CZZZQ e.g. 170334-19862
  
  ### Actual behavior
  
  fake.ssn() for latvian locale outputs ssn in format  'ddd-dd-dddd'
  '604-87-6475'
  '824-21-9489'
  '411-57-8156'
  '938-77-8408'
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `faker/providers/ssn/lv_LV/__init__.py`
  Content:
  ```
  1 from .. import Provider as BaseProvider
  2 
  3 
  4 class Provider(BaseProvider):
  5     """
  6     A Faker provider for the Latvian VAT IDs
  7     """
  8 
  9     vat_id_formats = ("LV###########",)
  10 
  11     def vat_id(self) -> str:
  12         """
  13         http://ec.europa.eu/taxation_customs/vies/faq.html#item_11
  14         :return: a random Latvian VAT ID
  15         """
  16 
  17         return self.bothify(self.random_element(self.vat_id_formats))
  18
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/faker/providers/ssn/lv_LV/__init__.py b/faker/providers/ssn/lv_LV/__init__.py
  --- a/faker/providers/ssn/lv_LV/__init__.py
  +++ b/faker/providers/ssn/lv_LV/__init__.py
  @@ -1,7 +1,56 @@
  -from .. import Provider as BaseProvider
  +import datetime
   
  +from .. import Provider as SsnProvider
  +
  +
  +class Provider(SsnProvider):
  +    def ssn(self, min_age: int = 0, max_age: int = 105) -> str:
  +        """
  +        Returns 11 character Latvian personal identity code (Personas kods).
  +        This function assigns random age to person.
  +
  +        Personal code consists of eleven characters of the form DDMMYYCZZZQ, where
  +        DDMMYY is the date of birth, C the century sign, ZZZ the individual
  +        number and Q the control character (checksum). The number for the
  +        century is either 0 (1800–1899), 1 (1900–1999), or 2 (2000–2099).
  +        """
  +
  +        def _checksum(ssn_without_checksum):
  +            weights = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2]
  +            weighted_sum = sum(int(digit) * weight for digit, weight in zip(ssn_without_checksum, weights))
  +            reminder = (1 - weighted_sum) % 11
  +            if reminder == 10:
  +                return 0
  +            elif reminder < -1:
  +                return reminder + 11
  +            return reminder
  +
  +        age = datetime.timedelta(days=self.generator.random.randrange(min_age * 365, max_age * 365))
  +        birthday = datetime.date.today() - age
  +        ssn_date = "%02d%02d%s" % (
  +            birthday.day,
  +            birthday.month,
  +            str(birthday.year)[-2:],
  +        )
  +        century = self._get_century_code(birthday.year)  # Century
  +        suffix = self.generator.random.randrange(111, 999)
  +        checksum = _checksum(f"{ssn_date}{century:01d}{suffix:03d}")
  +        ssn = f"{ssn_date}-{century:01d}{suffix:03d}{checksum:01d}"
  +        return ssn
  +
  +    @staticmethod
  +    def _get_century_code(year: int) -> int:
  +        """Returns the century code for a given year"""
  +        if 2000 <= year < 3000:
  +            code = 2
  +        elif 1900 <= year < 2000:
  +            code = 1
  +        elif 1800 <= year < 1900:
  +            code = 0
  +        else:
  +            raise ValueError("SSN do not support people born before the year 1800 or after the year 2999")
  +        return code
   
  -class Provider(BaseProvider):
       """
       A Faker provider for the Latvian VAT IDs
       """
  
verification_info: {"golden_diff": "diff --git a/faker/providers/ssn/lv_LV/__init__.py b/faker/providers/ssn/lv_LV/__init__.py\n--- a/faker/providers/ssn/lv_LV/__init__.py\n+++ b/faker/providers/ssn/lv_LV/__init__.py\n@@ -1,7 +1,56 @@\n-from .. import Provider as BaseProvider\n+import datetime\n \n+from .. import Provider as SsnProvider\n+\n+\n+class Provider(SsnProvider):\n+    def ssn(self, min_age: int = 0, max_age: int = 105) -> str:\n+        \"\"\"\n+        Returns 11 character Latvian personal identity code (Personas kods).\n+        This function assigns random age to person.\n+\n+        Personal code consists of eleven characters of the form DDMMYYCZZZQ, where\n+        DDMMYY is the date of birth, C the century sign, ZZZ the individual\n+        number and Q the control character (checksum). The number for the\n+        century is either 0 (1800\u20131899), 1 (1900\u20131999), or 2 (2000\u20132099).\n+        \"\"\"\n+\n+        def _checksum(ssn_without_checksum):\n+            weights = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2]\n+            weighted_sum = sum(int(digit) * weight for digit, weight in zip(ssn_without_checksum, weights))\n+            reminder = (1 - weighted_sum) % 11\n+            if reminder == 10:\n+                return 0\n+            elif reminder < -1:\n+                return reminder + 11\n+            return reminder\n+\n+        age = datetime.timedelta(days=self.generator.random.randrange(min_age * 365, max_age * 365))\n+        birthday = datetime.date.today() - age\n+        ssn_date = \"%02d%02d%s\" % (\n+            birthday.day,\n+            birthday.month,\n+            str(birthday.year)[-2:],\n+        )\n+        century = self._get_century_code(birthday.year)  # Century\n+        suffix = self.generator.random.randrange(111, 999)\n+        checksum = _checksum(f\"{ssn_date}{century:01d}{suffix:03d}\")\n+        ssn = f\"{ssn_date}-{century:01d}{suffix:03d}{checksum:01d}\"\n+        return ssn\n+\n+    @staticmethod\n+    def _get_century_code(year: int) -> int:\n+        \"\"\"Returns the century code for a given year\"\"\"\n+        if 2000 <= year < 3000:\n+            code = 2\n+        elif 1900 <= year < 2000:\n+            code = 1\n+        elif 1800 <= year < 1900:\n+            code = 0\n+        else:\n+            raise ValueError(\"SSN do not support people born before the year 1800 or after the year 2999\")\n+        return code\n \n-class Provider(BaseProvider):\n     \"\"\"\n     A Faker provider for the Latvian VAT IDs\n     \"\"\"\n", "issue": "Latvian ssn generator is not correct\n* Faker version: 17.0.0\r\n* OS: Windows\r\n\r\n\r\nLatvian ssn generator generates ssn in format 'ddd-dd-dddd', which is not correct. \r\n\r\n### Steps to reproduce\r\n\r\n```\r\nfrom faker import Faker\r\nfake = Faker('lv_LV')\r\nfake.ssn()\r\n\r\n```\r\n\r\n### Expected behavior\r\n\r\nIt should be 12 characters long DDMMYY-CZZZQ e.g. 170334-19862\r\n\r\n### Actual behavior\r\n\r\nfake.ssn() for latvian locale outputs ssn in format  'ddd-dd-dddd'\r\n'604-87-6475'\r\n'824-21-9489'\r\n'411-57-8156'\r\n'938-77-8408'\r\n\n", "before_files": [{"content": "from .. import Provider as BaseProvider\n\n\nclass Provider(BaseProvider):\n    \"\"\"\n    A Faker provider for the Latvian VAT IDs\n    \"\"\"\n\n    vat_id_formats = (\"LV###########\",)\n\n    def vat_id(self) -> str:\n        \"\"\"\n        http://ec.europa.eu/taxation_customs/vies/faq.html#item_11\n        :return: a random Latvian VAT ID\n        \"\"\"\n\n        return self.bothify(self.random_element(self.vat_id_formats))\n", "path": "faker/providers/ssn/lv_LV/__init__.py"}], "after_files": [{"content": "import datetime\n\nfrom .. import Provider as SsnProvider\n\n\nclass Provider(SsnProvider):\n    def ssn(self, min_age: int = 0, max_age: int = 105) -> str:\n        \"\"\"\n        Returns 11 character Latvian personal identity code (Personas kods).\n        This function assigns random age to person.\n\n        Personal code consists of eleven characters of the form DDMMYYCZZZQ, where\n        DDMMYY is the date of birth, C the century sign, ZZZ the individual\n        number and Q the control character (checksum). The number for the\n        century is either 0 (1800\u20131899), 1 (1900\u20131999), or 2 (2000\u20132099).\n        \"\"\"\n\n        def _checksum(ssn_without_checksum):\n            weights = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2]\n            weighted_sum = sum(int(digit) * weight for digit, weight in zip(ssn_without_checksum, weights))\n            reminder = (1 - weighted_sum) % 11\n            if reminder == 10:\n                return 0\n            elif reminder < -1:\n                return reminder + 11\n            return reminder\n\n        age = datetime.timedelta(days=self.generator.random.randrange(min_age * 365, max_age * 365))\n        birthday = datetime.date.today() - age\n        ssn_date = \"%02d%02d%s\" % (\n            birthday.day,\n            birthday.month,\n            str(birthday.year)[-2:],\n        )\n        century = self._get_century_code(birthday.year)  # Century\n        suffix = self.generator.random.randrange(111, 999)\n        checksum = _checksum(f\"{ssn_date}{century:01d}{suffix:03d}\")\n        ssn = f\"{ssn_date}-{century:01d}{suffix:03d}{checksum:01d}\"\n        return ssn\n\n    @staticmethod\n    def _get_century_code(year: int) -> int:\n        \"\"\"Returns the century code for a given year\"\"\"\n        if 2000 <= year < 3000:\n            code = 2\n        elif 1900 <= year < 2000:\n            code = 1\n        elif 1800 <= year < 1900:\n            code = 0\n        else:\n            raise ValueError(\"SSN do not support people born before the year 1800 or after the year 2999\")\n        return code\n\n    \"\"\"\n    A Faker provider for the Latvian VAT IDs\n    \"\"\"\n\n    vat_id_formats = (\"LV###########\",)\n\n    def vat_id(self) -> str:\n        \"\"\"\n        http://ec.europa.eu/taxation_customs/vies/faq.html#item_11\n        :return: a random Latvian VAT ID\n        \"\"\"\n\n        return self.bothify(self.random_element(self.vat_id_formats))\n", "path": "faker/providers/ssn/lv_LV/__init__.py"}]}