Example #1
0
def test_format_time_max_units():
    assert format_time(timedelta(hours=3, minutes=2, seconds=36),
                       max_units=1) == "3 h"
    assert format_time(timedelta(hours=3, minutes=2, seconds=36),
                       max_units=2) == "3 h 2 min"
    assert format_time(timedelta(hours=3, minutes=2, seconds=36),
                       max_units=3) == "3 h 2 min 36 s"
    assert format_time(timedelta(hours=3, minutes=2, seconds=36),
                       max_units=None) == "3 h 2 min 36 s"
Example #2
0
def test_format_time_min_unit():
    assert format_time(timedelta(hours=3, minutes=2, seconds=36),
                       min_unit=TimeUnit.DAYS,
                       max_units=None) == "< 1 d"
    assert format_time(timedelta(hours=3, minutes=2, seconds=36),
                       min_unit=TimeUnit.HOURS,
                       max_units=None) == "3 h"
    assert format_time(timedelta(hours=3, minutes=2, seconds=36),
                       min_unit=TimeUnit.MINUTES,
                       max_units=None) == "3 h 2 min"
    assert format_time(timedelta(hours=3, minutes=2, seconds=36),
                       min_unit=TimeUnit.SECONDS,
                       max_units=None) == "3 h 2 min 36 s"
    assert format_time(timedelta(hours=3, minutes=2, seconds=36),
                       min_unit=None,
                       max_units=None) == "3 h 2 min 36 s"
Example #3
0
def test_format_time_numeric_deltatime():
    assert format_time(10956, min_unit=None,
                       max_units=None) == "3 h 2 min 36 s"
Example #4
0
def test_format_time():
    assert format_time(timedelta(minutes=2, seconds=36)) == "2 min 36 s"
Example #5
0
async def cmd_ping(command: Command):
    await command.respond(
        format_time(
            delta_time=command.client.
            latency,  # `client.latency` is a second representation.
            min_unit=TimeUnit.MILLISECONDS))