Use ISO format for timestamps in names

This commit is contained in:
Serene-Arc
2021-04-22 10:38:32 +10:00
parent 2eab4052c5
commit d960bc0b7b
2 changed files with 22 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# coding=utf-8
import datetime
import logging
import platform
import re
@@ -74,10 +74,15 @@ class FileNameFormatter:
'postid': submission.id,
'upvotes': submission.score,
'flair': submission.link_flair_text,
'date': submission.created_utc
'date': FileNameFormatter._convert_timestamp(submission.created_utc),
}
return submission_attributes
@staticmethod
def _convert_timestamp(timestamp: float) -> str:
input_time = datetime.datetime.fromtimestamp(timestamp)
return input_time.isoformat()
@staticmethod
def _generate_name_dict_from_comment(comment: Comment) -> dict:
comment_attributes = {
@@ -87,7 +92,7 @@ class FileNameFormatter:
'postid': comment.id,
'upvotes': comment.score,
'flair': '',
'date': comment.created_utc,
'date': FileNameFormatter._convert_timestamp(comment.created_utc),
}
return comment_attributes