Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions chat_downloader/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ def base64_encode(text):


def timestamp_to_microseconds(timestamp):
"""Convert RFC3339 timestamp to microseconds. This is needed since
``datetime.datetime.strptime()`` does not support nanosecond precision.
"""Convert ISO 8601 timestamp to microseconds.

:param timestamp: RFC3339 timestamp
:param timestamp: ISO 8601 timestamp
:type timestamp: str
:return: The number of microseconds of the timestamp
:rtype: int
"""

info = list(filter(None, re.split(r'[\.|Z]{1}', timestamp))) + [0]
return round((datetime.datetime.strptime(f'{info[0]}Z', '%Y-%m-%dT%H:%M:%SZ').timestamp() + float(f'0.{info[1]}')) * 1e6)
return int(datetime.datetime.fromisoformat(timestamp).timestamp() * 1e6)


def time_to_seconds(time):
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
author_email=metadata['__email__'],
url=metadata['__url__'],
version=metadata['__version__'],
python_requires='>=3.6',
python_requires='>=3.7',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
Expand Down