diff --git a/bot/exts/practices/_practice_sessions.py b/bot/exts/practices/_practice_sessions.py index f73d2348..fe7e5863 100644 --- a/bot/exts/practices/_practice_sessions.py +++ b/bot/exts/practices/_practice_sessions.py @@ -11,7 +11,7 @@ from bot.utils.datetimes import ( PACIFIC, PACIFIC_CURRENT_NAME, - format_multi_time, + format_datetime, parse_human_readable_datetime, utcnow, ) @@ -113,7 +113,7 @@ async def make_practice_session_embed( else: num_sessions = len(sessions) for session in sessions: - title = format_multi_time(session.dtime) + title = format_datetime(session.dtime, format_type="t") gcal_event_title = ( f"ASL Practice: {truncate(session.notes, 50)}" if session.notes diff --git a/bot/exts/practices/daily_message.py b/bot/exts/practices/daily_message.py index ae739f13..6f97be96 100644 --- a/bot/exts/practices/daily_message.py +++ b/bot/exts/practices/daily_message.py @@ -17,7 +17,7 @@ from bot.utils.datetimes import ( EASTERN, PACIFIC, - format_multi_time, + format_datetime, parse_human_readable_datetime, utcnow, ) @@ -156,7 +156,7 @@ async def send_daily_message( ) for event in events_today: embed.add_field( - name=format_multi_time(event.scheduled_start_time), + name=format_datetime(event.scheduled_start_time, format_type="t"), value=f"{event.name} ยท [Details/RSVP]({get_event_url(event)})", inline=False, ) diff --git a/bot/exts/practices/practice.py b/bot/exts/practices/practice.py index bbf122ea..25383914 100644 --- a/bot/exts/practices/practice.py +++ b/bot/exts/practices/practice.py @@ -18,7 +18,7 @@ PACIFIC_CURRENT_NAME, NoTimeZoneError, display_timezone, - format_multi_time, + format_datetime, parse_human_readable_datetime, utcnow, ) @@ -204,8 +204,7 @@ async def practice_impl( logger.info(f"adding new practice session to sheet: {row}") worksheet = await get_practice_worksheet_for_guild(guild_id) worksheet.append_row(row) - dtime_pacific = dtime.astimezone(PACIFIC) - short_display_date = f"{dtime_pacific:%a, %b %d} {format_multi_time(dtime)}" + short_display_date = format_datetime(dtime) sessions = await get_practice_sessions( guild_id=guild_id, dtime=dtime, worksheet=worksheet ) diff --git a/bot/exts/schedule.py b/bot/exts/schedule.py index 3a79302e..6bb66b1b 100644 --- a/bot/exts/schedule.py +++ b/bot/exts/schedule.py @@ -23,6 +23,7 @@ PACIFIC_CURRENT_NAME, NoTimeZoneError, display_timezone, + format_datetime, format_multi_time, utcnow, ) @@ -70,6 +71,7 @@ def format_scheduled_start_time_date(dtime: dt.datetime): def format_scheduled_start_time(dtime: dt.datetime): + # NOTE: format doesn't work in dropdown labels return format_scheduled_start_time_date(dtime) + " ยท " + format_multi_time(dtime) @@ -462,7 +464,7 @@ async def _prompt_for_start_time( await start_time_message.edit( content=( "โ˜‘๏ธ **When will your event start?**\n" - f"Entered: {format_scheduled_start_time(scheduled_start_time)}" + f"Entered: {format_datetime(scheduled_start_time, format_type='F')}" ) ) return scheduled_start_time, used_timezone diff --git a/bot/utils/datetimes.py b/bot/utils/datetimes.py index 82c546a3..5243efed 100644 --- a/bot/utils/datetimes.py +++ b/bot/utils/datetimes.py @@ -73,6 +73,10 @@ def display_timezone(tzinfo: StaticTzInfo, dtime: dt.datetime) -> str: return ret +def format_datetime(dtime: dt.datetime, format_type="f") -> str: + return f"" + + def display_time(dtime: dt.datetime, time_format: str, tzinfo: StaticTzInfo) -> str: return dtime.astimezone(tzinfo).strftime(time_format) + display_timezone( tzinfo, dtime diff --git a/script/server b/script/server index 33107a7a..934127dc 100755 --- a/script/server +++ b/script/server @@ -1,4 +1,5 @@ #!/bin/sh set -eo pipefail +docker-compose up -d DEBUG=true python -m bot diff --git a/tests/bot/exts/__snapshots__/test_practice.ambr b/tests/bot/exts/__snapshots__/test_practice.ambr index c9d413e3..e5c06413 100644 --- a/tests/bot/exts/__snapshots__/test_practice.ambr +++ b/tests/bot/exts/__snapshots__/test_practice.ambr @@ -103,7 +103,7 @@ colour=, description='Today - Friday, September 25', fields= [ - EmbedProxy(inline=False, name='2 PM PDT / 3 PM MDT / 4 PM CDT / 5 PM EDT', value='[+Google Calendar](http://www.google.com/calendar/event?action=TEMPLATE&text=ASL+Practice%3A+recurring&dates=20200925T210000Z%2F20200925T220000Z&details=See+the+full+schedule+here%3A+https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fabc%2Fedit)\n> Host: <@!12345>\n> Details: recurring'), + EmbedProxy(inline=False, name='', value='[+Google Calendar](http://www.google.com/calendar/event?action=TEMPLATE&text=ASL+Practice%3A+recurring&dates=20200925T210000Z%2F20200925T220000Z&details=See+the+full+schedule+here%3A+https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fabc%2Fedit)\n> Host: <@!12345>\n> Details: recurring'), EmbedProxy(inline=True, name='๐Ÿ—“ View or edit the schedule using the link below.', value='[Full schedule](https://docs.google.com/spreadsheets/d/abc/edit)'), ], footer=EmbedProxy(), @@ -127,7 +127,7 @@ colour=, description='Today - Friday, September 25', fields= [ - EmbedProxy(inline=False, name='2 PM PDT / 3 PM MDT / 4 PM CDT / 5 PM EDT', value='[+Google Calendar](http://www.google.com/calendar/event?action=TEMPLATE&text=ASL+Practice%3A+recurring&dates=20200925T210000Z%2F20200925T220000Z&details=See+the+full+schedule+here%3A+https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fabc%2Fedit)\n> Host: <@!12345>\n> Details: recurring'), + EmbedProxy(inline=False, name='', value='[+Google Calendar](http://www.google.com/calendar/event?action=TEMPLATE&text=ASL+Practice%3A+recurring&dates=20200925T210000Z%2F20200925T220000Z&details=See+the+full+schedule+here%3A+https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fabc%2Fedit)\n> Host: <@!12345>\n> Details: recurring'), EmbedProxy(inline=True, name='๐Ÿ—“ View or edit the schedule using the link below.', value='[Full schedule](https://docs.google.com/spreadsheets/d/abc/edit)'), ], footer=EmbedProxy(), @@ -151,7 +151,7 @@ colour=, description='Today - Thursday, November 26 ๐Ÿฆƒ', fields= [ - EmbedProxy(inline=False, name='11 AM PST / 12 PM MST / 1 PM CST / 2 PM EST', value='[+Google Calendar](http://www.google.com/calendar/event?action=TEMPLATE&text=ASL+Practice%3A+Turkey+day+PRACTICE&dates=20201126T190000Z%2F20201126T200000Z&details=See+the+full+schedule+here%3A+https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fabc%2Fedit)\n> Details: Turkey day PRACTICE'), + EmbedProxy(inline=False, name='', value='[+Google Calendar](http://www.google.com/calendar/event?action=TEMPLATE&text=ASL+Practice%3A+Turkey+day+PRACTICE&dates=20201126T190000Z%2F20201126T200000Z&details=See+the+full+schedule+here%3A+https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fabc%2Fedit)\n> Details: Turkey day PRACTICE'), EmbedProxy(inline=True, name='๐Ÿ—“ View or edit the schedule using the link below.', value='[Full schedule](https://docs.google.com/spreadsheets/d/abc/edit)'), ], footer=EmbedProxy(),