class TweepyUtilsTests(unittest.TestCase):
- def testparse_datetime(self):
- result = parse_datetime("Wed Aug 27 13:08:45 +0000 2008")
- self.assertEqual(datetime(2008, 8, 27, 13, 8, 45), result)
-
def testlist_to_csv(self):
self.assertEqual("1,2,3", list_to_csv([1,2,3]))
self.assertEqual("bird,tweet,nest,egg",
list_to_csv(["bird", "tweet", "nest", "egg"]))
-
# Copyright 2009-2021 Joshua Roesslein
# See LICENSE for details.
+from email.utils import parsedate_to_datetime
+
from tweepy.mixins import Hashable
-from tweepy.utils import parse_a_href, parse_datetime, parse_html_value
+from tweepy.utils import parse_a_href, parse_html_value
class ResultSet(list):
setattr(status, 'author', user)
setattr(status, 'user', user) # DEPRECIATED
elif k == 'created_at':
- setattr(status, k, parse_datetime(v))
+ setattr(status, k, parsedate_to_datetime(v))
elif k == 'source':
if '<' in v:
setattr(status, k, parse_html_value(v))
setattr(user, '_json', json)
for k, v in json.items():
if k == 'created_at':
- setattr(user, k, parse_datetime(v))
+ setattr(user, k, parsedate_to_datetime(v))
elif k == 'status':
setattr(user, k, Status.parse(api, v))
elif k == 'following':
ss = cls(api)
for k, v in json.items():
if k == 'created_at':
- setattr(ss, k, parse_datetime(v))
+ setattr(ss, k, parsedate_to_datetime(v))
else:
setattr(ss, k, v)
return ss
if k == 'user':
setattr(lst, k, User.parse(api, v))
elif k == 'created_at':
- setattr(lst, k, parse_datetime(v))
+ setattr(lst, k, parsedate_to_datetime(v))
else:
setattr(lst, k, v)
return lst
# Copyright 2010-2021 Joshua Roesslein
# See LICENSE for details.
-from datetime import datetime
-from email.utils import parsedate
-
-
-def parse_datetime(string):
- return datetime(*(parsedate(string)[:6]))
-
def parse_html_value(html):
return html[html.find('>')+1:html.rfind('<')]