adjust formatting of times and durations

pull/1/head
qwewqa 4 years ago
parent 30a9a45437
commit 99291165ff
  1. 11
      miyu_bot/commands/cogs/event.py
  2. 4
      miyu_bot/commands/cogs/music.py

@ -6,7 +6,8 @@ from d4dj_utils.master.event_master import EventMaster, EventState
from discord.ext import commands from discord.ext import commands
from main import asset_manager from main import asset_manager
from miyu_bot.commands.common.emoji import attribute_emoji_ids_by_attribute_id, unit_emoji_ids_by_unit_id, parameter_bonus_emoji_ids_by_parameter_id, \ from miyu_bot.commands.common.emoji import attribute_emoji_ids_by_attribute_id, unit_emoji_ids_by_unit_id, \
parameter_bonus_emoji_ids_by_parameter_id, \
event_point_emoji_id event_point_emoji_id
from miyu_bot.commands.common.formatting import format_info from miyu_bot.commands.common.formatting import format_info
from miyu_bot.commands.common.fuzzy_matching import FuzzyMap, romanize from miyu_bot.commands.common.fuzzy_matching import FuzzyMap, romanize
@ -52,9 +53,15 @@ class Event(commands.Cog):
embed = discord.Embed(title=event.name) embed = discord.Embed(title=event.name)
embed.set_thumbnail(url=f'attachment://logo.png') embed.set_thumbnail(url=f'attachment://logo.png')
duration_hour_part = round((event.duration.seconds / 3600), 2)
duration_hour_part = duration_hour_part if not duration_hour_part.is_integer() else int(duration_hour_part)
duration_hours = round((event.duration.days * 24 + event.duration.seconds / 3600), 2)
duration_hours = duration_hours if not duration_hours.is_integer() else int(duration_hours)
embed.add_field(name='Dates', embed.add_field(name='Dates',
value=format_info({ value=format_info({
'Duration': event.duration, 'Duration': f'{event.duration.days} days, {duration_hour_part} hours '
f'({duration_hours} hours)',
'Start': event.start_datetime, 'Start': event.start_datetime,
'Close': event.reception_close_datetime, 'Close': event.reception_close_datetime,
'Rank Fix': event.rank_fix_start_datetime, 'Rank Fix': event.rank_fix_start_datetime,

@ -288,7 +288,9 @@ class Music(commands.Cog):
return duration return duration
def format_duration(self, seconds): def format_duration(self, seconds):
return f'{int(seconds // 60)}m {round(seconds % 60, 2)}s' minutes = int(seconds // 60)
seconds = round(seconds % 60, 2)
return f'{minutes}:{str(int(seconds)).zfill(2)}.{str(int(seconds % 1 * 100)).zfill(2)}'
def setup(bot): def setup(bot):

Loading…
Cancel
Save