print the time remaining, i don't think it's perfect yet though
This commit is contained in:
parent
aeb015568e
commit
fabf38c736
1 changed files with 21 additions and 2 deletions
23
listing.py
23
listing.py
|
@ -1,6 +1,6 @@
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
import re, json
|
import re, json, math
|
||||||
from datetime import datetime, timezone, timedelta
|
from datetime import datetime, timezone, timedelta
|
||||||
|
|
||||||
import functions
|
import functions
|
||||||
|
@ -116,6 +116,8 @@ class YahooAuctionsItem:
|
||||||
if self.name == None or self.name == "":
|
if self.name == None or self.name == "":
|
||||||
self.name = j['productName']
|
self.name = j['productName']
|
||||||
|
|
||||||
|
self.available = (self.end_date_local() >= datetime.now(LOCALTIME))
|
||||||
|
|
||||||
self.ready = True
|
self.ready = True
|
||||||
self.updating = False
|
self.updating = False
|
||||||
|
|
||||||
|
@ -145,7 +147,24 @@ class YahooAuctionsItem:
|
||||||
return self.start_date.astimezone(LOCALTIME)
|
return self.start_date.astimezone(LOCALTIME)
|
||||||
|
|
||||||
def ending_in(self, local = False):
|
def ending_in(self, local = False):
|
||||||
return "heenlo"
|
if local:
|
||||||
|
difference = self.end_date_local() - datetime.now(tz = LOCALTIME)
|
||||||
|
else:
|
||||||
|
difference = self.end_date - datetime.now(tz = JST)
|
||||||
|
|
||||||
|
ds = int(difference.total_seconds())
|
||||||
|
|
||||||
|
seconds = ds % 60
|
||||||
|
minutes = math.floor(ds / 60) % 60
|
||||||
|
hours = math.floor(ds / (60 * 60)) % 24
|
||||||
|
days = math.floor(ds / (60 * 60 * 24))
|
||||||
|
|
||||||
|
out = ""
|
||||||
|
if days > 0: out += f"{days}d "
|
||||||
|
if hours > 0: out += f"{hours}h "
|
||||||
|
if minutes > 0: out += f"{minutes}m "
|
||||||
|
|
||||||
|
return f"{out}{seconds}s"
|
||||||
|
|
||||||
def ending_at(self, local = False):
|
def ending_at(self, local = False):
|
||||||
now = datetime.now(tz = LOCALTIME)
|
now = datetime.now(tz = LOCALTIME)
|
||||||
|
|
Loading…
Reference in a new issue