We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Use UTC dates
https://github.com/python-telegram-bot/python-telegram-bot/blob/439790375ed8ed493c43e464aa8e2b60a77939db/telegram/utils/helpers.py#L78-L90

Should probably be using `tz=timezone.utc`. Python's `datetime` isn't the best, and `fromtimestamp` by default sets no `tz` information, which uses the local time, which in turn is generally a bad idea.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `telegram/utils/helpers.py`
Content:
```
1 #!/usr/bin/env python
2 #
3 # A library that provides a Python interface to the Telegram Bot API
4 # Copyright (C) 2015-2018
5 # Leandro Toledo de Souza <devs@python-telegram-bot.org>
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Lesser Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU Lesser Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser Public License
18 # along with this program.  If not, see [http://www.gnu.org/licenses/].
19 """This module contains helper functions."""
20 from collections import defaultdict
21 
22 try:
23     import ujson as json
24 except ImportError:
25     import json
26 from html import escape
27 
28 import re
29 import signal
30 from datetime import datetime
31 
32 # From https://stackoverflow.com/questions/2549939/get-signal-names-from-numbers-in-python
33 _signames = {v: k
34              for k, v in reversed(sorted(vars(signal).items()))
35              if k.startswith('SIG') and not k.startswith('SIG_')}
36 
37 
38 def get_signal_name(signum):
39     """Returns the signal name of the given signal number."""
40     return _signames[signum]
41 
42 
43 # Not using future.backports.datetime here as datetime value might be an input from the user,
44 # making every isinstace() call more delicate. So we just use our own compat layer.
45 if hasattr(datetime, 'timestamp'):
46     # Python 3.3+
47     def _timestamp(dt_obj):
48         return dt_obj.timestamp()
49 else:
50     # Python < 3.3 (incl 2.7)
51     from time import mktime
52 
53     def _timestamp(dt_obj):
54         return mktime(dt_obj.timetuple())
55 
56 
57 def escape_markdown(text):
58     """Helper function to escape telegram markup symbols."""
59     escape_chars = '\*_`\['
60     return re.sub(r'([%s])' % escape_chars, r'\\\1', text)
61 
62 
63 def to_timestamp(dt_obj):
64     """
65     Args:
66         dt_obj (:class:`datetime.datetime`):
67 
68     Returns:
69         int:
70 
71     """
72     if not dt_obj:
73         return None
74 
75     return int(_timestamp(dt_obj))
76 
77 
78 def from_timestamp(unixtime):
79     """
80     Args:
81         unixtime (int):
82 
83     Returns:
84         datetime.datetime:
85 
86     """
87     if not unixtime:
88         return None
89 
90     return datetime.fromtimestamp(unixtime)
91 
92 
93 def mention_html(user_id, name):
94     """
95     Args:
96         user_id (:obj:`int`) The user's id which you want to mention.
97         name (:obj:`str`) The name the mention is showing.
98 
99     Returns:
100         :obj:`str`: The inline mention for the user as html.
101     """
102     if isinstance(user_id, int):
103         return u'<a href="tg://user?id={}">{}</a>'.format(user_id, escape(name))
104 
105 
106 def mention_markdown(user_id, name):
107     """
108     Args:
109         user_id (:obj:`int`) The user's id which you want to mention.
110         name (:obj:`str`) The name the mention is showing.
111 
112     Returns:
113         :obj:`str`: The inline mention for the user as markdown.
114     """
115     if isinstance(user_id, int):
116         return u'[{}](tg://user?id={})'.format(escape_markdown(name), user_id)
117 
118 
119 def effective_message_type(entity):
120     """
121     Extracts the type of message as a string identifier from a :class:`telegram.Message` or a
122     :class:`telegram.Update`.
123 
124     Args:
125         entity (:obj:`Update` | :obj:`Message`) The ``update`` or ``message`` to extract from
126 
127     Returns:
128         str: One of ``Message.MESSAGE_TYPES``
129 
130     """
131 
132     # Importing on file-level yields cyclic Import Errors
133     from telegram import Message
134     from telegram import Update
135 
136     if isinstance(entity, Message):
137         message = entity
138     elif isinstance(entity, Update):
139         message = entity.effective_message
140     else:
141         raise TypeError("entity is not Message or Update (got: {})".format(type(entity)))
142 
143     for i in Message.MESSAGE_TYPES:
144         if getattr(message, i, None):
145             return i
146 
147     return None
148 
149 
150 def enocde_conversations_to_json(conversations):
151     """Helper method to encode a conversations dict (that uses tuples as keys) to a
152     JSON-serializable way. Use :attr:`_decode_conversations_from_json` to decode.
153 
154     Args:
155         conversations (:obj:`dict`): The conversations dict to transofrm to JSON.
156 
157     Returns:
158         :obj:`str`: The JSON-serialized conversations dict
159     """
160     tmp = {}
161     for handler, states in conversations.items():
162         tmp[handler] = {}
163         for key, state in states.items():
164             tmp[handler][json.dumps(key)] = state
165     return json.dumps(tmp)
166 
167 
168 def decode_conversations_from_json(json_string):
169     """Helper method to decode a conversations dict (that uses tuples as keys) from a
170     JSON-string created with :attr:`_encode_conversations_to_json`.
171 
172     Args:
173         json_string (:obj:`str`): The conversations dict as JSON string.
174 
175     Returns:
176         :obj:`dict`: The conversations dict after decoding
177     """
178     tmp = json.loads(json_string)
179     conversations = {}
180     for handler, states in tmp.items():
181         conversations[handler] = {}
182         for key, state in states.items():
183             conversations[handler][tuple(json.loads(key))] = state
184     return conversations
185 
186 
187 def decode_user_chat_data_from_json(data):
188     """Helper method to decode chat or user data (that uses ints as keys) from a
189     JSON-string.
190 
191     Args:
192         data (:obj:`str`): The user/chat_data dict as JSON string.
193 
194     Returns:
195         :obj:`dict`: The user/chat_data defaultdict after decoding
196     """
197 
198     tmp = defaultdict(dict)
199     decoded_data = json.loads(data)
200     for user, data in decoded_data.items():
201         user = int(user)
202         tmp[user] = {}
203         for key, value in data.items():
204             try:
205                 key = int(key)
206             except ValueError:
207                 pass
208             tmp[user][key] = value
209     return tmp
210
```
--- 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()

```

diff --git a/telegram/utils/helpers.py b/telegram/utils/helpers.py
--- a/telegram/utils/helpers.py
+++ b/telegram/utils/helpers.py
@@ -87,7 +87,7 @@
     if not unixtime:
         return None
 
-    return datetime.fromtimestamp(unixtime)
+    return datetime.utcfromtimestamp(unixtime)
 
 
 def mention_html(user_id, name):

{"golden_diff": "diff --git a/telegram/utils/helpers.py b/telegram/utils/helpers.py\n--- a/telegram/utils/helpers.py\n+++ b/telegram/utils/helpers.py\n@@ -87,7 +87,7 @@\n     if not unixtime:\n         return None\n \n-    return datetime.fromtimestamp(unixtime)\n+    return datetime.utcfromtimestamp(unixtime)\n \n \n def mention_html(user_id, name):\n", "issue": "Use UTC dates\nhttps://github.com/python-telegram-bot/python-telegram-bot/blob/439790375ed8ed493c43e464aa8e2b60a77939db/telegram/utils/helpers.py#L78-L90\r\n\r\nShould probably be using `tz=timezone.utc`. Python's `datetime` isn't the best, and `fromtimestamp` by default sets no `tz` information, which uses the local time, which in turn is generally a bad idea.\n", "before_files": [{"content": "#!/usr/bin/env python\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2018\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\"This module contains helper functions.\"\"\"\nfrom collections import defaultdict\n\ntry:\n    import ujson as json\nexcept ImportError:\n    import json\nfrom html import escape\n\nimport re\nimport signal\nfrom datetime import datetime\n\n# From https://stackoverflow.com/questions/2549939/get-signal-names-from-numbers-in-python\n_signames = {v: k\n             for k, v in reversed(sorted(vars(signal).items()))\n             if k.startswith('SIG') and not k.startswith('SIG_')}\n\n\ndef get_signal_name(signum):\n    \"\"\"Returns the signal name of the given signal number.\"\"\"\n    return _signames[signum]\n\n\n# Not using future.backports.datetime here as datetime value might be an input from the user,\n# making every isinstace() call more delicate. So we just use our own compat layer.\nif hasattr(datetime, 'timestamp'):\n    # Python 3.3+\n    def _timestamp(dt_obj):\n        return dt_obj.timestamp()\nelse:\n    # Python < 3.3 (incl 2.7)\n    from time import mktime\n\n    def _timestamp(dt_obj):\n        return mktime(dt_obj.timetuple())\n\n\ndef escape_markdown(text):\n    \"\"\"Helper function to escape telegram markup symbols.\"\"\"\n    escape_chars = '\\*_`\\['\n    return re.sub(r'([%s])' % escape_chars, r'\\\\\\1', text)\n\n\ndef to_timestamp(dt_obj):\n    \"\"\"\n    Args:\n        dt_obj (:class:`datetime.datetime`):\n\n    Returns:\n        int:\n\n    \"\"\"\n    if not dt_obj:\n        return None\n\n    return int(_timestamp(dt_obj))\n\n\ndef from_timestamp(unixtime):\n    \"\"\"\n    Args:\n        unixtime (int):\n\n    Returns:\n        datetime.datetime:\n\n    \"\"\"\n    if not unixtime:\n        return None\n\n    return datetime.fromtimestamp(unixtime)\n\n\ndef mention_html(user_id, name):\n    \"\"\"\n    Args:\n        user_id (:obj:`int`) The user's id which you want to mention.\n        name (:obj:`str`) The name the mention is showing.\n\n    Returns:\n        :obj:`str`: The inline mention for the user as html.\n    \"\"\"\n    if isinstance(user_id, int):\n        return u'<a href=\"tg://user?id={}\">{}</a>'.format(user_id, escape(name))\n\n\ndef mention_markdown(user_id, name):\n    \"\"\"\n    Args:\n        user_id (:obj:`int`) The user's id which you want to mention.\n        name (:obj:`str`) The name the mention is showing.\n\n    Returns:\n        :obj:`str`: The inline mention for the user as markdown.\n    \"\"\"\n    if isinstance(user_id, int):\n        return u'[{}](tg://user?id={})'.format(escape_markdown(name), user_id)\n\n\ndef effective_message_type(entity):\n    \"\"\"\n    Extracts the type of message as a string identifier from a :class:`telegram.Message` or a\n    :class:`telegram.Update`.\n\n    Args:\n        entity (:obj:`Update` | :obj:`Message`) The ``update`` or ``message`` to extract from\n\n    Returns:\n        str: One of ``Message.MESSAGE_TYPES``\n\n    \"\"\"\n\n    # Importing on file-level yields cyclic Import Errors\n    from telegram import Message\n    from telegram import Update\n\n    if isinstance(entity, Message):\n        message = entity\n    elif isinstance(entity, Update):\n        message = entity.effective_message\n    else:\n        raise TypeError(\"entity is not Message or Update (got: {})\".format(type(entity)))\n\n    for i in Message.MESSAGE_TYPES:\n        if getattr(message, i, None):\n            return i\n\n    return None\n\n\ndef enocde_conversations_to_json(conversations):\n    \"\"\"Helper method to encode a conversations dict (that uses tuples as keys) to a\n    JSON-serializable way. Use :attr:`_decode_conversations_from_json` to decode.\n\n    Args:\n        conversations (:obj:`dict`): The conversations dict to transofrm to JSON.\n\n    Returns:\n        :obj:`str`: The JSON-serialized conversations dict\n    \"\"\"\n    tmp = {}\n    for handler, states in conversations.items():\n        tmp[handler] = {}\n        for key, state in states.items():\n            tmp[handler][json.dumps(key)] = state\n    return json.dumps(tmp)\n\n\ndef decode_conversations_from_json(json_string):\n    \"\"\"Helper method to decode a conversations dict (that uses tuples as keys) from a\n    JSON-string created with :attr:`_encode_conversations_to_json`.\n\n    Args:\n        json_string (:obj:`str`): The conversations dict as JSON string.\n\n    Returns:\n        :obj:`dict`: The conversations dict after decoding\n    \"\"\"\n    tmp = json.loads(json_string)\n    conversations = {}\n    for handler, states in tmp.items():\n        conversations[handler] = {}\n        for key, state in states.items():\n            conversations[handler][tuple(json.loads(key))] = state\n    return conversations\n\n\ndef decode_user_chat_data_from_json(data):\n    \"\"\"Helper method to decode chat or user data (that uses ints as keys) from a\n    JSON-string.\n\n    Args:\n        data (:obj:`str`): The user/chat_data dict as JSON string.\n\n    Returns:\n        :obj:`dict`: The user/chat_data defaultdict after decoding\n    \"\"\"\n\n    tmp = defaultdict(dict)\n    decoded_data = json.loads(data)\n    for user, data in decoded_data.items():\n        user = int(user)\n        tmp[user] = {}\n        for key, value in data.items():\n            try:\n                key = int(key)\n            except ValueError:\n                pass\n            tmp[user][key] = value\n    return tmp\n", "path": "telegram/utils/helpers.py"}], "after_files": [{"content": "#!/usr/bin/env python\n#\n# A library that provides a Python interface to the Telegram Bot API\n# Copyright (C) 2015-2018\n# Leandro Toledo de Souza <devs@python-telegram-bot.org>\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Lesser Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Lesser Public License for more details.\n#\n# You should have received a copy of the GNU Lesser Public License\n# along with this program.  If not, see [http://www.gnu.org/licenses/].\n\"\"\"This module contains helper functions.\"\"\"\nfrom collections import defaultdict\n\ntry:\n    import ujson as json\nexcept ImportError:\n    import json\nfrom html import escape\n\nimport re\nimport signal\nfrom datetime import datetime\n\n# From https://stackoverflow.com/questions/2549939/get-signal-names-from-numbers-in-python\n_signames = {v: k\n             for k, v in reversed(sorted(vars(signal).items()))\n             if k.startswith('SIG') and not k.startswith('SIG_')}\n\n\ndef get_signal_name(signum):\n    \"\"\"Returns the signal name of the given signal number.\"\"\"\n    return _signames[signum]\n\n\n# Not using future.backports.datetime here as datetime value might be an input from the user,\n# making every isinstace() call more delicate. So we just use our own compat layer.\nif hasattr(datetime, 'timestamp'):\n    # Python 3.3+\n    def _timestamp(dt_obj):\n        return dt_obj.timestamp()\nelse:\n    # Python < 3.3 (incl 2.7)\n    from time import mktime\n\n    def _timestamp(dt_obj):\n        return mktime(dt_obj.timetuple())\n\n\ndef escape_markdown(text):\n    \"\"\"Helper function to escape telegram markup symbols.\"\"\"\n    escape_chars = '\\*_`\\['\n    return re.sub(r'([%s])' % escape_chars, r'\\\\\\1', text)\n\n\ndef to_timestamp(dt_obj):\n    \"\"\"\n    Args:\n        dt_obj (:class:`datetime.datetime`):\n\n    Returns:\n        int:\n\n    \"\"\"\n    if not dt_obj:\n        return None\n\n    return int(_timestamp(dt_obj))\n\n\ndef from_timestamp(unixtime):\n    \"\"\"\n    Args:\n        unixtime (int):\n\n    Returns:\n        datetime.datetime:\n\n    \"\"\"\n    if not unixtime:\n        return None\n\n    return datetime.utcfromtimestamp(unixtime)\n\n\ndef mention_html(user_id, name):\n    \"\"\"\n    Args:\n        user_id (:obj:`int`) The user's id which you want to mention.\n        name (:obj:`str`) The name the mention is showing.\n\n    Returns:\n        :obj:`str`: The inline mention for the user as html.\n    \"\"\"\n    if isinstance(user_id, int):\n        return u'<a href=\"tg://user?id={}\">{}</a>'.format(user_id, escape(name))\n\n\ndef mention_markdown(user_id, name):\n    \"\"\"\n    Args:\n        user_id (:obj:`int`) The user's id which you want to mention.\n        name (:obj:`str`) The name the mention is showing.\n\n    Returns:\n        :obj:`str`: The inline mention for the user as markdown.\n    \"\"\"\n    if isinstance(user_id, int):\n        return u'[{}](tg://user?id={})'.format(escape_markdown(name), user_id)\n\n\ndef effective_message_type(entity):\n    \"\"\"\n    Extracts the type of message as a string identifier from a :class:`telegram.Message` or a\n    :class:`telegram.Update`.\n\n    Args:\n        entity (:obj:`Update` | :obj:`Message`) The ``update`` or ``message`` to extract from\n\n    Returns:\n        str: One of ``Message.MESSAGE_TYPES``\n\n    \"\"\"\n\n    # Importing on file-level yields cyclic Import Errors\n    from telegram import Message\n    from telegram import Update\n\n    if isinstance(entity, Message):\n        message = entity\n    elif isinstance(entity, Update):\n        message = entity.effective_message\n    else:\n        raise TypeError(\"entity is not Message or Update (got: {})\".format(type(entity)))\n\n    for i in Message.MESSAGE_TYPES:\n        if getattr(message, i, None):\n            return i\n\n    return None\n\n\ndef enocde_conversations_to_json(conversations):\n    \"\"\"Helper method to encode a conversations dict (that uses tuples as keys) to a\n    JSON-serializable way. Use :attr:`_decode_conversations_from_json` to decode.\n\n    Args:\n        conversations (:obj:`dict`): The conversations dict to transofrm to JSON.\n\n    Returns:\n        :obj:`str`: The JSON-serialized conversations dict\n    \"\"\"\n    tmp = {}\n    for handler, states in conversations.items():\n        tmp[handler] = {}\n        for key, state in states.items():\n            tmp[handler][json.dumps(key)] = state\n    return json.dumps(tmp)\n\n\ndef decode_conversations_from_json(json_string):\n    \"\"\"Helper method to decode a conversations dict (that uses tuples as keys) from a\n    JSON-string created with :attr:`_encode_conversations_to_json`.\n\n    Args:\n        json_string (:obj:`str`): The conversations dict as JSON string.\n\n    Returns:\n        :obj:`dict`: The conversations dict after decoding\n    \"\"\"\n    tmp = json.loads(json_string)\n    conversations = {}\n    for handler, states in tmp.items():\n        conversations[handler] = {}\n        for key, state in states.items():\n            conversations[handler][tuple(json.loads(key))] = state\n    return conversations\n\n\ndef decode_user_chat_data_from_json(data):\n    \"\"\"Helper method to decode chat or user data (that uses ints as keys) from a\n    JSON-string.\n\n    Args:\n        data (:obj:`str`): The user/chat_data dict as JSON string.\n\n    Returns:\n        :obj:`dict`: The user/chat_data defaultdict after decoding\n    \"\"\"\n\n    tmp = defaultdict(dict)\n    decoded_data = json.loads(data)\n    for user, data in decoded_data.items():\n        user = int(user)\n        tmp[user] = {}\n        for key, value in data.items():\n            try:\n                key = int(key)\n            except ValueError:\n                pass\n            tmp[user][key] = value\n    return tmp\n", "path": "telegram/utils/helpers.py"}]}