prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [Bug]: date time issue
  ### I Have A Problem With:
  
  The integration in general
  
  ### What's Your Problem
  
  Used to work. No change in cfg.
  At some point, after an upgrade…
  Integration fails while starting. See log.
  
  ### Source (if relevant)
  
  _No response_
  
  ### Logs
  
  ```Shell
  Denne feilen stammer fra en tilpasset integrasjon.
  
  Logger: waste_collection_schedule.source_shell
  Source: custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py:136
  Integration: waste_collection_schedule (documentation)
  First occurred: 19:02:11 (1 occurrences)
  Last logged: 19:02:11
  
  fetch failed for source Stavanger Kommune: Traceback (most recent call last): File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py", line 134, in fetch entries = self._source.fetch() ^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py", line 63, in fetch date = datetime.strptime(date[0] + "." + year, "%d.%m.%Y").date() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/_strptime.py", line 534, in _strptime julian = datetime_date(year, month, day).toordinal() - \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: day is out of range for month
  ```
  
  
  ### Relevant Configuration
  
  ```YAML
  name: stavanger_no
  
  municipality: Stavanger
  ```
  
  
  ### Checklist Source Error
  
  - [ ] Use the example parameters for your source (often available in the documentation) (don't forget to restart Home Assistant after changing the configuration)
  - [X] Checked that the website of your service provider is still working
  - [X] Tested my attributes on the service provider website (if possible)
  - [X] I have tested with the latest version of the integration (master) (for HACS in the 3 dot menu of the integration click on "Redownload" and choose master as version)
  
  ### Checklist Sensor Error
  
  - [ ] Checked in the Home Assistant Calendar tab if the event names match the types names (if types argument is used)
  
  ### Required
  
  - [X] I have searched past (closed AND opened) issues to see if this bug has already been reported, and it hasn't been.
  - [X] I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.
  
  </issue>
  <code>
  [start of custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py]
  1 from datetime import datetime
  2 
  3 import requests
  4 from bs4 import BeautifulSoup
  5 from waste_collection_schedule import Collection  # type: ignore[attr-defined]
  6 
  7 TITLE = "Stavanger Kommune"
  8 DESCRIPTION = "Source for Stavanger Kommune, Norway"
  9 URL = "https://www.stavanger.kommune.no/"
  10 TEST_CASES = {
  11     "TestcaseI": {
  12         "id": "57bf9d36-722e-400b-ae93-d80f8e354724",
  13         "municipality": "Stavanger",
  14         "gnumber": "57",
  15         "bnumber": "922",
  16         "snumber": "0",
  17     },
  18 }
  19 
  20 ICON_MAP = {
  21     "Restavfall": "mdi:trash-can",
  22     "Papp/papir": "mdi:recycle",
  23     "Bio": "mdi:leaf",
  24     "Juletre": "mdi:pine-tree",
  25 }
  26 
  27 
  28 class Source:
  29     def __init__(self, id, municipality, gnumber, bnumber, snumber):
  30         self._id = id
  31         self._municipality = municipality
  32         self._gnumber = gnumber
  33         self._bnumber = bnumber
  34         self._snumber = snumber
  35 
  36     def fetch(self):
  37         url = "https://www.stavanger.kommune.no/renovasjon-og-miljo/tommekalender/finn-kalender/show"
  38         headers = {"referer": "https://www.stavanger.kommune.no"}
  39 
  40         params = {
  41             "id": self._id,
  42             "municipality": self._municipality,
  43             "gnumber": self._gnumber,
  44             "bnumber": self._bnumber,
  45             "snumber": self._snumber,
  46         }
  47 
  48         r = requests.get(url, params=params, headers=headers)
  49         r.raise_for_status()
  50 
  51         soup = BeautifulSoup(r.text, "html.parser")
  52 
  53         tag = soup.find_all("option")
  54         year = tag[0].get("value").split("-")
  55         year = year[1]
  56 
  57         entries = []
  58         for tag in soup.find_all("tr", {"class": "waste-calendar__item"}):
  59             if tag.text.strip() == "Dato og dag\nAvfallstype":
  60                 continue
  61 
  62             date = tag.text.strip().split(" - ")
  63             date = datetime.strptime(date[0] + "." + year, "%d.%m.%Y").date()
  64 
  65             for img in tag.find_all("img"):
  66                 waste_type = img.get("title")
  67                 entries.append(
  68                     Collection(date, waste_type, icon=ICON_MAP.get(waste_type))
  69                 )
  70 
  71         return entries
  72
  [end of custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py
  --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py
  +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py
  @@ -51,14 +51,12 @@
           soup = BeautifulSoup(r.text, "html.parser")
   
           tag = soup.find_all("option")
  -        year = tag[0].get("value").split("-")
  -        year = year[1]
  -
           entries = []
           for tag in soup.find_all("tr", {"class": "waste-calendar__item"}):
               if tag.text.strip() == "Dato og dag\nAvfallstype":
                   continue
   
  +            year = tag.parent.attrs["data-month"].split("-")[1]
               date = tag.text.strip().split(" - ")
               date = datetime.strptime(date[0] + "." + year, "%d.%m.%Y").date()
  
verification_info: {"golden_diff": "diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py\n--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py\n+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py\n@@ -51,14 +51,12 @@\n         soup = BeautifulSoup(r.text, \"html.parser\")\n \n         tag = soup.find_all(\"option\")\n-        year = tag[0].get(\"value\").split(\"-\")\n-        year = year[1]\n-\n         entries = []\n         for tag in soup.find_all(\"tr\", {\"class\": \"waste-calendar__item\"}):\n             if tag.text.strip() == \"Dato og dag\\nAvfallstype\":\n                 continue\n \n+            year = tag.parent.attrs[\"data-month\"].split(\"-\")[1]\n             date = tag.text.strip().split(\" - \")\n             date = datetime.strptime(date[0] + \".\" + year, \"%d.%m.%Y\").date()\n", "issue": "[Bug]: date time issue\n### I Have A Problem With:\n\nThe integration in general\n\n### What's Your Problem\n\nUsed to work. No change in cfg.\r\nAt some point, after an upgrade\u2026\r\nIntegration fails while starting. See log.\n\n### Source (if relevant)\n\n_No response_\n\n### Logs\n\n```Shell\nDenne feilen stammer fra en tilpasset integrasjon.\r\n\r\nLogger: waste_collection_schedule.source_shell\r\nSource: custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py:136\r\nIntegration: waste_collection_schedule (documentation)\r\nFirst occurred: 19:02:11 (1 occurrences)\r\nLast logged: 19:02:11\r\n\r\nfetch failed for source Stavanger Kommune: Traceback (most recent call last): File \"/config/custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py\", line 134, in fetch entries = self._source.fetch() ^^^^^^^^^^^^^^^^^^^^ File \"/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py\", line 63, in fetch date = datetime.strptime(date[0] + \".\" + year, \"%d.%m.%Y\").date() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File \"/usr/local/lib/python3.11/_strptime.py\", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File \"/usr/local/lib/python3.11/_strptime.py\", line 534, in _strptime julian = datetime_date(year, month, day).toordinal() - \\ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: day is out of range for month\n```\n\n\n### Relevant Configuration\n\n```YAML\nname: stavanger_no\r\n\r\nmunicipality: Stavanger\n```\n\n\n### Checklist Source Error\n\n- [ ] Use the example parameters for your source (often available in the documentation) (don't forget to restart Home Assistant after changing the configuration)\n- [X] Checked that the website of your service provider is still working\n- [X] Tested my attributes on the service provider website (if possible)\n- [X] I have tested with the latest version of the integration (master) (for HACS in the 3 dot menu of the integration click on \"Redownload\" and choose master as version)\n\n### Checklist Sensor Error\n\n- [ ] Checked in the Home Assistant Calendar tab if the event names match the types names (if types argument is used)\n\n### Required\n\n- [X] I have searched past (closed AND opened) issues to see if this bug has already been reported, and it hasn't been.\n- [X] I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.\n", "before_files": [{"content": "from datetime import datetime\n\nimport requests\nfrom bs4 import BeautifulSoup\nfrom waste_collection_schedule import Collection  # type: ignore[attr-defined]\n\nTITLE = \"Stavanger Kommune\"\nDESCRIPTION = \"Source for Stavanger Kommune, Norway\"\nURL = \"https://www.stavanger.kommune.no/\"\nTEST_CASES = {\n    \"TestcaseI\": {\n        \"id\": \"57bf9d36-722e-400b-ae93-d80f8e354724\",\n        \"municipality\": \"Stavanger\",\n        \"gnumber\": \"57\",\n        \"bnumber\": \"922\",\n        \"snumber\": \"0\",\n    },\n}\n\nICON_MAP = {\n    \"Restavfall\": \"mdi:trash-can\",\n    \"Papp/papir\": \"mdi:recycle\",\n    \"Bio\": \"mdi:leaf\",\n    \"Juletre\": \"mdi:pine-tree\",\n}\n\n\nclass Source:\n    def __init__(self, id, municipality, gnumber, bnumber, snumber):\n        self._id = id\n        self._municipality = municipality\n        self._gnumber = gnumber\n        self._bnumber = bnumber\n        self._snumber = snumber\n\n    def fetch(self):\n        url = \"https://www.stavanger.kommune.no/renovasjon-og-miljo/tommekalender/finn-kalender/show\"\n        headers = {\"referer\": \"https://www.stavanger.kommune.no\"}\n\n        params = {\n            \"id\": self._id,\n            \"municipality\": self._municipality,\n            \"gnumber\": self._gnumber,\n            \"bnumber\": self._bnumber,\n            \"snumber\": self._snumber,\n        }\n\n        r = requests.get(url, params=params, headers=headers)\n        r.raise_for_status()\n\n        soup = BeautifulSoup(r.text, \"html.parser\")\n\n        tag = soup.find_all(\"option\")\n        year = tag[0].get(\"value\").split(\"-\")\n        year = year[1]\n\n        entries = []\n        for tag in soup.find_all(\"tr\", {\"class\": \"waste-calendar__item\"}):\n            if tag.text.strip() == \"Dato og dag\\nAvfallstype\":\n                continue\n\n            date = tag.text.strip().split(\" - \")\n            date = datetime.strptime(date[0] + \".\" + year, \"%d.%m.%Y\").date()\n\n            for img in tag.find_all(\"img\"):\n                waste_type = img.get(\"title\")\n                entries.append(\n                    Collection(date, waste_type, icon=ICON_MAP.get(waste_type))\n                )\n\n        return entries\n", "path": "custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py"}]}