diff --git a/cogs/modCommands.py b/cogs/modCommands.py index 5091baf..2b19d46 100644 --- a/cogs/modCommands.py +++ b/cogs/modCommands.py @@ -170,7 +170,7 @@ class ModCommands(commands.Cog): created_local = timeFormatters.epochToDate(user.created_at.timestamp()) - embed.add_field(name="Account Aangemaakt", value="{}\n({} Geleden)".format( + embed.add_field(name="Account Aangemaakt", value="{}\n({} geleden)".format( created_local["date"], timeFormatters.diffYearBasisString(round(created_local["dateDT"].timestamp())) ), inline=False) diff --git a/cogs/poke.py b/cogs/poke.py index 3a384e1..a61d324 100644 --- a/cogs/poke.py +++ b/cogs/poke.py @@ -58,7 +58,7 @@ class Poke(commands.Cog): @poke.command(name="Current") async def current(self, ctx): p = poke.get() - pokedTimeStamp = datetime.datetime.fromtimestamp(int(p[1])) + pokedTimeStamp = timeFormatters.epochToDate(int(p[1]))["dateDT"] timeString = timeFormatters.diffDayBasisString(pokedTimeStamp) await ctx.send("Het is al **{}** aan **{}**.".format(timeString, self.utilsCog.getDisplayName(ctx, p[0]))) diff --git a/functions/timeFormatters.py b/functions/timeFormatters.py index 8cf2424..272c321 100644 --- a/functions/timeFormatters.py +++ b/functions/timeFormatters.py @@ -82,7 +82,6 @@ def diffYearBasisString(timestamp): timestamp = epochToDate(timestamp)["dateDT"] now = dateTimeNow() diff = dateutil.relativedelta.relativedelta(now, timestamp) - timeList = [] # Don't add obsolete info such as "0 days", ... @@ -98,10 +97,18 @@ def diffYearBasisString(timestamp): if diff.days != 0: timeList.append("{} {}".format(diff.days, getPlural(diff.days, "days"))) - timeString = ", ".join(timeList[:-1]) + timeString = "" + + if not timeList: + return "Minder dan een dag" + + if len(timeList) > 1: + timeString = ", ".join(timeList[:-1]) if len(timeString) > 0: timeString += " en " + timeString += timeList[-1] + return timeString