From 5bdeb7a4d72af6b0a6d8eefcf80a70425112f1a8 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 8 Jun 2021 01:28:39 +0200 Subject: [PATCH] fix tz in whois command --- src/cogs/utils.py | 6 +++--- src/utils/time.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cogs/utils.py b/src/cogs/utils.py index 63bce56..a4e73e4 100644 --- a/src/cogs/utils.py +++ b/src/cogs/utils.py @@ -6,7 +6,7 @@ from random import randint, shuffle from discord_slash import cog_ext from utils.reminder import Reminder from utils.core import map_list_among_us, getURLsInString, getMentionInString, cleanCodeStringWithMentionAndURLs, cleanUser, userOrNick -from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString, timestampScreen, getAge, ageLayout, nowCustom, UTCDatetimeToCustomDatetime +from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString, timestampScreen, getAge, ageLayout, nowCustom def setup(client): client.add_cog(Utils(client)) @@ -362,13 +362,13 @@ class Utils(commands.Cog): embed.add_field(name = "Compte créé le", value = timestampScreen(user[0].created_at)) - embed.add_field(name = "Âge du compte", value = ageLayout(getAge(UTCDatetimeToCustomDatetime(user[0].created_at)))) + embed.add_field(name = "Âge du compte", value = ageLayout(getAge(user[0].created_at))) embed.add_field(name = "Mention", value = user[0].mention) embed.add_field(name = "Serveur rejoint le", value = timestampScreen(user[0].joined_at)) - embed.add_field(name = "Est sur le serveur depuis", value = ageLayout(getAge(UTCDatetimeToCustomDatetime(user[0].joined_at)))) + embed.add_field(name = "Est sur le serveur depuis", value = ageLayout(getAge(user[0].joined_at))) if fromSlash != True: await ctx.message.add_reaction(emoji = '✅') return await ctx.send(embed = embed) diff --git a/src/utils/time.py b/src/utils/time.py index b53e8f5..64442a2 100644 --- a/src/utils/time.py +++ b/src/utils/time.py @@ -72,18 +72,19 @@ def timedeltaToString(time): return ''.join(age) def getAge(date): - """Recupère un age précisément à la seconde près""" - joursRestants = intToDatetime(nowCustom()) - date + """Recupère un âge précisément à la seconde près""" + heureAjouter = int(str(UTCDatetimeToCustomDatetime(intToDatetime(nowUTC()))).split('+')[1].split(':')[0]) + joursRestants = intToDatetime(nowUTC()) - date years = joursRestants.total_seconds() / (365.242 * 24 * 3600) months = (years - int(years)) * 12 days = (months - int(months)) * (365.242 / 12) hours = (days - int(days)) * 24 minutes = (hours - int(hours)) * 60 seconds = (minutes - int(minutes)) * 60 - return (int(years), int(months), int(days), int(hours), int(minutes), int(seconds)) + return (int(years), int(months), int(days), int(hours) + heureAjouter, int(minutes), int(seconds)) def ageLayout(tuple): - """avec la méthode 'getAge', permet de mettre en forme un âge⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢""" + """Avec la méthode `getAge`, permet de mettre en forme un âge⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢""" time = {} time[0], time[1], time[2], time[3], time[4], time[5] = "an", "mois", "jour", "heure", "minute", "seconde" for i in range(len(tuple)):