mirror of https://github.com/stijndcl/didier
Fix train timestamps
parent
c8946fdc49
commit
f6c324d656
|
@ -94,7 +94,7 @@ class Corona(commands.Cog):
|
||||||
inline=False)
|
inline=False)
|
||||||
|
|
||||||
# Timestamp of last update
|
# Timestamp of last update
|
||||||
timeFormatted = timeFormatters.epochToDate(dic["today"]["updated"])
|
timeFormatted = timeFormatters.epochToDate(int(dic["today"]["updated"])/1000)
|
||||||
embed.set_footer(text="Laatst geüpdatet op {} ({} geleden)".format(
|
embed.set_footer(text="Laatst geüpdatet op {} ({} geleden)".format(
|
||||||
timeFormatted["date"], timeFormatted["timeAgo"]))
|
timeFormatted["date"], timeFormatted["timeAgo"]))
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
@ -146,7 +146,7 @@ class Corona(commands.Cog):
|
||||||
distribution[0], distribution[1], distribution[2]), inline=False)
|
distribution[0], distribution[1], distribution[2]), inline=False)
|
||||||
|
|
||||||
# Timestamp of last update
|
# Timestamp of last update
|
||||||
timeFormatted = timeFormatters.epochToDate(dic["today"]["updated"])
|
timeFormatted = timeFormatters.epochToDate(int(dic["today"]["updated"])/1000)
|
||||||
embed.set_footer(text="Laatst geüpdatet op {} ({} geleden)".format(
|
embed.set_footer(text="Laatst geüpdatet op {} ({} geleden)".format(
|
||||||
timeFormatted["date"], timeFormatted["timeAgo"]))
|
timeFormatted["date"], timeFormatted["timeAgo"]))
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
|
@ -4,7 +4,7 @@ from decorators import help
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands, menus
|
from discord.ext import commands, menus
|
||||||
from enums.help_categories import Category
|
from enums.help_categories import Category
|
||||||
from functions import checks
|
from functions import checks, timeFormatters
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class Train(commands.Cog):
|
||||||
return str(minutes) + "m"
|
return str(minutes) + "m"
|
||||||
return "{}h{:02}m".format(minutes // 60, minutes % 60)
|
return "{}h{:02}m".format(minutes // 60, minutes % 60)
|
||||||
else:
|
else:
|
||||||
return datetime.datetime.fromtimestamp(int(timestamp)).strftime("%H:%M")
|
return timeFormatters.epochToDate(int(timestamp), "%H:%M")["date"]
|
||||||
|
|
||||||
def formatDelay(self, seconds):
|
def formatDelay(self, seconds):
|
||||||
seconds = int(seconds)
|
seconds = int(seconds)
|
||||||
|
|
|
@ -5,11 +5,11 @@ import dateutil.relativedelta
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
|
|
||||||
def epochToDate(epochTimeStamp):
|
def epochToDate(epochTimeStamp, strFormat="%m/%d/%Y om %H:%M:%S"):
|
||||||
now = dateTimeNow()
|
now = dateTimeNow()
|
||||||
updateTime = datetime.datetime.fromtimestamp(int(epochTimeStamp) / 1000, pytz.timezone("Europe/Brussels"))
|
updateTime = datetime.datetime.fromtimestamp(int(epochTimeStamp), pytz.timezone("Europe/Brussels"))
|
||||||
diff = now - updateTime
|
diff = now - updateTime
|
||||||
updateFormatted = str(updateTime.strftime('%m/%d/%Y om %H:%M:%S'))
|
updateFormatted = str(updateTime.strftime(strFormat))
|
||||||
timeAgo = str(time.strftime('%H:%M:%S', time.gmtime(diff.total_seconds())))
|
timeAgo = str(time.strftime('%H:%M:%S', time.gmtime(diff.total_seconds())))
|
||||||
return {"date": updateFormatted, "timeAgo": timeAgo}
|
return {"date": updateFormatted, "timeAgo": timeAgo}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue