Example #1
0
def getFormatTime(obj, varname):
    """
    Returns the value obj.varname as a formatted time string using 
    L{rpg.timeutil.formatTime}, assuming of course that the value represents 
    seconds since the epoch.  Also if the time value is 0, then the string 
    'unknown' is returned.
    
    >>> getFormatTime({'a': 0}, 'a')
    'unknown'

    >>> getFormatTime({'a': None}, 'a')
    'unknown'

    >>> getFormatTime({'a': 1}, 'a')
    '12/31|16:00'

    >>> try:
    ...   getFormatTime({'a': 'blah'}, 'a')
    ... except TypeError:
    ...   pass

    """

    val = getVal(obj, varname)
    if not val:
        return 'unknown'
    return timeutil.formatTime(val)
Example #2
0
def getFormatTime(obj, varname):
    """
    Returns the value obj.varname as a formatted time string using 
    L{rpg.timeutil.formatTime}, assuming of course that the value represents 
    seconds since the epoch.  Also if the time value is 0, then the string 
    'unknown' is returned.
    
    >>> getFormatTime({'a': 0}, 'a')
    'unknown'

    >>> getFormatTime({'a': None}, 'a')
    'unknown'

    >>> getFormatTime({'a': 1}, 'a')
    '12/31|16:00'

    >>> try:
    ...   getFormatTime({'a': 'blah'}, 'a')
    ... except TypeError:
    ...   pass

    """

    val = getVal(obj, varname)
    if not val:
        return 'unknown'
    return timeutil.formatTime(val)