Simplify date handling
This commit is contained in:
parent
bf481ebcee
commit
6f5fc86c8a
|
@ -9,7 +9,6 @@ import urllib3
|
||||||
import logging
|
import logging
|
||||||
from elasticsearch import Elasticsearch
|
from elasticsearch import Elasticsearch
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import builtins
|
|
||||||
|
|
||||||
# Project imports
|
# Project imports
|
||||||
from settings import settings
|
from settings import settings
|
||||||
|
@ -377,14 +376,15 @@ class Money(util.Base):
|
||||||
|
|
||||||
# Reformat the date how CoinGecko likes
|
# Reformat the date how CoinGecko likes
|
||||||
# 2022-05-02T11:17:14+00:00
|
# 2022-05-02T11:17:14+00:00
|
||||||
try:
|
if "+" in created_at:
|
||||||
date_parsed = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S.%fZ")
|
|
||||||
except builtins.ValueError:
|
|
||||||
date_split = created_at.split("+")
|
date_split = created_at.split("+")
|
||||||
date_split[1].replace(".", "")
|
date_split[1].replace(".", "")
|
||||||
date_split[1].replace(":", "")
|
date_split[1].replace(":", "")
|
||||||
created_at = "+".join(date_split)
|
created_at = "+".join(date_split)
|
||||||
date_parsed = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S%Z")
|
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")
|
date_formatted = date_parsed.strftime("%d-%m-%Y")
|
||||||
|
|
||||||
# Get the historical rates for the right asset, extract the price
|
# Get the historical rates for the right asset, extract the price
|
||||||
|
|
Loading…
Reference in New Issue