Properly represent date and time in FeedItem DTO #30

Closed
opened 2022-07-09 16:28:21 +00:00 by skobkin · 0 comments
Collaborator

Currently we're getting date and time as time.struct_time tuple which is pretty inconvenient.

It's better to convert that to the time.datetime to be able to use nice formatting options (like strftime() or isoformat() out of the box.

# Use time.mktime() to convert the time tuple (in localtime) into seconds since the Epoch, then use datetime.fromtimestamp() to get the datetime object

from datetime import datetime
from time import mktime

dt = datetime.fromtimestamp(mktime(struct))
Currently we're getting date and time as [`time.struct_time`](https://docs.python.org/3/library/time.html#time.struct_time) tuple which is pretty inconvenient. It's better to convert that to the [`time.datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) to be able to use nice formatting options (like `strftime()` or `isoformat()` out of the box. ```python # Use time.mktime() to convert the time tuple (in localtime) into seconds since the Epoch, then use datetime.fromtimestamp() to get the datetime object from datetime import datetime from time import mktime dt = datetime.fromtimestamp(mktime(struct)) ```
skobkin added this to the MVP 0.1 milestone 2022-07-09 16:28:21 +00:00
skobkin added the
enhancement
label 2022-07-09 16:28:21 +00:00
Miroslavsckaya was assigned by skobkin 2022-07-09 16:28:21 +00:00
skobkin added this to the RSS Bot Kanban Perdoling project 2022-07-09 16:28:21 +00:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Miroslavsckaya/tg_rss_bot#30
No description provided.