Simplify date handling

master
Mark Veidemanis 2 years ago
parent bf481ebcee
commit 6f5fc86c8a
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -9,7 +9,6 @@ import urllib3
import logging
from elasticsearch import Elasticsearch
from datetime import datetime
import builtins
# Project imports
from settings import settings
@ -377,14 +376,15 @@ class Money(util.Base):
# Reformat the date how CoinGecko likes
# 2022-05-02T11:17:14+00:00
try:
date_parsed = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S.%fZ")
except builtins.ValueError:
if "+" in created_at:
date_split = created_at.split("+")
date_split[1].replace(".", "")
date_split[1].replace(":", "")
created_at = "+".join(date_split)
date_parsed = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S%Z")
else:
date_parsed = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S.%fZ")
date_formatted = date_parsed.strftime("%d-%m-%Y")
# Get the historical rates for the right asset, extract the price

Loading…
Cancel
Save