Fix date handling
This commit is contained in:
parent
be3b97ae42
commit
ac7a76a1de
|
@ -9,6 +9,7 @@ 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
|
||||||
|
@ -194,7 +195,7 @@ class Money(util.Base):
|
||||||
"profit_usd": profit,
|
"profit_usd": profit,
|
||||||
}
|
}
|
||||||
|
|
||||||
self.tx.write_to_es("get_profit", cast_es)
|
self.write_to_es("get_profit", cast_es)
|
||||||
return profit
|
return profit
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
|
@ -376,7 +377,14 @@ 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:
|
||||||
date_parsed = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S.%fZ")
|
date_parsed = datetime.strptime(created_at, "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||||
|
except builtins.ValueError:
|
||||||
|
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")
|
||||||
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
|
||||||
|
|
|
@ -122,8 +122,8 @@ def last_online_recent(date):
|
||||||
# for LBTC
|
# for LBTC
|
||||||
# 2022-04-16T08:53:58+00:00
|
# 2022-04-16T08:53:58+00:00
|
||||||
date_split = date.split("+")
|
date_split = date.split("+")
|
||||||
date[1].replace(".", "")
|
date_split[1].replace(".", "")
|
||||||
date[1].replace(":", "")
|
date_split[1].replace(":", "")
|
||||||
date = "+".join(date_split)
|
date = "+".join(date_split)
|
||||||
date_string = "%Y-%m-%dT%H:%M:%S%z"
|
date_string = "%Y-%m-%dT%H:%M:%S%z"
|
||||||
now = datetime.now(timezone.utc)
|
now = datetime.now(timezone.utc)
|
||||||
|
|
Loading…
Reference in New Issue