Add debugging output to figure out why the times are wrong
All checks were successful
docker-image / docker (push) Successful in 10m0s
All checks were successful
docker-image / docker (push) Successful in 10m0s
This commit is contained in:
parent
441b1a2890
commit
2e4e0d072d
1 changed files with 17 additions and 10 deletions
|
@ -6,6 +6,7 @@ from time import sleep
|
||||||
|
|
||||||
from buba.bubacmd import BubaCmd
|
from buba.bubacmd import BubaCmd
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
WEEKDAYS_DE = [
|
WEEKDAYS_DE = [
|
||||||
"Mo",
|
"Mo",
|
||||||
|
@ -40,6 +41,19 @@ class BubaAnimation:
|
||||||
it = iter(it)
|
it = iter(it)
|
||||||
return iter(lambda: tuple(islice(it, size)), ())
|
return iter(lambda: tuple(islice(it, size)), ())
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def humanize_delta(dt, now_delta, day_delta):
|
||||||
|
if now_delta < timedelta(seconds=60):
|
||||||
|
return "jetzt"
|
||||||
|
if now_delta < timedelta(minutes=90):
|
||||||
|
return f"{int(now_delta.seconds / 60)}m"
|
||||||
|
if day_delta < timedelta(hours=24):
|
||||||
|
return f"{int((now_delta.seconds + 3599) / 3600)}h"
|
||||||
|
if day_delta < timedelta(days=7):
|
||||||
|
# return dt.strftime("%a") # weekday
|
||||||
|
return WEEKDAYS_DE[dt.weekday()]
|
||||||
|
return dt.strftime("%d.%m.")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def countdown(dt: datetime):
|
def countdown(dt: datetime):
|
||||||
"""
|
"""
|
||||||
|
@ -51,16 +65,9 @@ class BubaAnimation:
|
||||||
from_day_start = now.replace(hour=4, minute=0, second=0, microsecond=0)
|
from_day_start = now.replace(hour=4, minute=0, second=0, microsecond=0)
|
||||||
now_delta = dt - now
|
now_delta = dt - now
|
||||||
day_delta = dt - from_day_start
|
day_delta = dt - from_day_start
|
||||||
if now_delta < timedelta(seconds=60):
|
h = BubaAnimation.humanize_delta(dt, now_delta, day_delta)
|
||||||
return "jetzt"
|
LOG.info(f"countdown({dt}) {now_delta} {day_delta} {h}")
|
||||||
if now_delta < timedelta(minutes=30):
|
return h
|
||||||
return f"{int(now_delta.seconds / 60)}m"
|
|
||||||
if day_delta < timedelta(hours=24):
|
|
||||||
return f"{int((now_delta.seconds + 3599) / 3600)}h"
|
|
||||||
if day_delta < timedelta(days=7):
|
|
||||||
# return dt.strftime("%a") # weekday
|
|
||||||
return WEEKDAYS_DE[dt.weekday()]
|
|
||||||
return dt.strftime("%d.%m.")
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def ellipsis(text, max=28):
|
def ellipsis(text, max=28):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue