fix bug d'affichage avec les heures du reminder
This commit is contained in:
parent
c09c791f12
commit
e801be8362
1 changed files with 13 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
||||||
from pytz import timezone
|
from pytz import timezone
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from re import findall
|
from re import findall, sub
|
||||||
from utils.core import load
|
from utils.core import load
|
||||||
|
|
||||||
myTimezone = load(["TIMEZONE"])["TIMEZONE"]
|
myTimezone = load(["TIMEZONE"])["TIMEZONE"]
|
||||||
|
@ -56,20 +56,21 @@ def timestampScreen(timestamp):
|
||||||
|
|
||||||
def timedeltaToString(time):
|
def timedeltaToString(time):
|
||||||
"""Différence entre une heure en seconde et maintenant"""
|
"""Différence entre une heure en seconde et maintenant"""
|
||||||
age = str(timedelta(seconds = time)).replace('day', 'jour').replace(', ', ':').split(':')
|
age = sub(r' days?, ', ':', str(timedelta(seconds = time))).split(':')
|
||||||
if len(age) == 4:
|
affichage = [1, 1, 1, 1] # len(age) == 4
|
||||||
a = [1, 1, 1, 1] # a pour affichage
|
|
||||||
if len(age) == 3:
|
if len(age) == 3:
|
||||||
a = [0, 1, 1, 1]
|
affichage = [0, 1, 1, 1]
|
||||||
age.insert(0, None)
|
age.insert(0, None)
|
||||||
for i in range(1, 4):
|
for i in range(1, len(affichage)):
|
||||||
if int(age[i]) == 0:
|
if int(age[i]) == 0:
|
||||||
a[i] = 0
|
affichage[i] = 0
|
||||||
age[0] = age[0] if a[0] == 1 else ''
|
age[0] = f"{age[0]} jour{'s' if int(age[0]) > 1 else ''}" if affichage[0] == 1 else ''
|
||||||
age[1] = f", {age[1]}h " if a[1] == 1 else ''
|
age[1] = f"{age[1]}h" if affichage[1] == 1 else ''
|
||||||
age[2] = f"{age[2]}m " if a[2] == 1 else ''
|
age[2] = f"{age[2]}m" if affichage[2] == 1 else ''
|
||||||
age[3] = f"{age[3]}s" if a[3] == 1 else ''
|
age[3] = f"{age[3]}s" if affichage[3] == 1 else ''
|
||||||
return ''.join(age).strip(' ')
|
while "" in age:
|
||||||
|
age.remove("")
|
||||||
|
return ', '.join(age).strip(' ')
|
||||||
|
|
||||||
def getAge(date):
|
def getAge(date):
|
||||||
"""Décompose la différence entre une date et maintenant avec les bons timezone"""
|
"""Décompose la différence entre une date et maintenant avec les bons timezone"""
|
||||||
|
|
Reference in a new issue