Changeset - a70552534acd
[Not reviewed]
0 1 0
Lance Edgar (lance) - 7 years ago 2018-02-12 17:43:39
lance@edbob.org
Tweak `util.pretty_hours()` logic per python 3
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rattail/util.py
Show inline comments
 
@@ -178,25 +178,25 @@ def hours_as_decimal(hours):
 

	
 
def pretty_hours(hours=None, seconds=None):
 
    """
 
    Format the given ``hours`` value (which is assumed to be a
 
    ``datetime.timedelta`` object) as HH:MM.  Note that instead of providing
 
    that, you can provide ``seconds`` instead and a delta will be generated.
 
    """
 
    if hours is None and seconds is None:
 
        return ''
 
    if hours is None:
 
        hours = datetime.timedelta(seconds=seconds)
 
    minutes = (hours.days * 1440) + (hours.seconds / 60)
 
    return '{}:{:02d}'.format(minutes // 60, minutes % 60)
 
    return "{}:{:02d}".format(int(minutes // 60), int(minutes % 60))
 

	
 

	
 
def pretty_quantity(value, empty_zero=False):
 
    """
 
    Return a "pretty" version of the given value, as string.  This is meant primarily
 
    for use with things like order quantities, so that e.g. 1.0000 => 1
 
    """
 
    if value is None:
 
        return ''
 
    if int(value) == value:
 
        value = int(value)
 
        if empty_zero and value == 0:
0 comments (0 inline, 0 general)