You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
448 B
17 lines
448 B
# -*- coding: utf-8 -*-
|
|
import string
|
|
from datetime import timedelta, datetime
|
|
|
|
class DeltaTemplate(string.Template):
|
|
delimiter = "%"
|
|
|
|
|
|
def strfdelta(tdelta, fmt):
|
|
d = {"D": tdelta.days}
|
|
hours, rem = divmod(tdelta.seconds, 3600)
|
|
minutes, seconds = divmod(rem, 60)
|
|
d["H"] = '{:02d}'.format(hours)
|
|
d["M"] = '{:02d}'.format(minutes)
|
|
d["S"] = '{:02d}'.format(seconds)
|
|
t = DeltaTemplate(fmt)
|
|
return t.substitute(**d)
|
|
|