2019-08-24 12:14:46 +00:00
|
|
|
import re
|
|
|
|
|
2019-08-27 12:34:51 +00:00
|
|
|
from datetime import datetime
|
|
|
|
|
2019-08-24 12:14:46 +00:00
|
|
|
HASHTAG_PATTERN = re.compile(r'(?<!\w)(#\w+)\b')
|
|
|
|
|
|
|
|
|
|
|
|
def highlight_hashtags(line):
|
|
|
|
return [
|
|
|
|
("hashtag", p) if p.startswith("#") else p
|
|
|
|
for p in re.split(HASHTAG_PATTERN, line)
|
|
|
|
]
|
2019-08-27 12:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
def parse_datetime(value):
|
|
|
|
"""Returns an aware datetime in local timezone"""
|
|
|
|
return datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z").astimezone()
|