示例#1
0
 def get_duration(self, obj):
     return calculate_duration_time(obj.start, obj.end)
示例#2
0
def test_duration_time_minutes():
    start = timezone.now()
    end = start + datetime.timedelta(minutes=10)
    duration = calculate_duration_time(start, end)

    assert duration == "0h10m0s"
示例#3
0
def test_duration_time_hours():
    start = timezone.now()
    end = start + datetime.timedelta(hours=2)
    duration = calculate_duration_time(start, end)

    assert duration == "2h0m0s"
示例#4
0
def test_duration_time_various_days():
    start = timezone.now()
    end = start + datetime.timedelta(days=3, hours=5, minutes=16, seconds=55)
    duration = calculate_duration_time(start, end)

    assert duration == "77h16m55s"
示例#5
0
def test_duration_time_seconds():
    start = timezone.now()
    end = start + datetime.timedelta(seconds=35)
    duration = calculate_duration_time(start, end)

    assert duration == "0h0m35s"