Did I find the right examples for you? yes no

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)
>>> datetime2float(datetime.timedelta(seconds=1))
1.0

>>> f = datetime2float(datetime.timedelta(weeks=2, seconds=20.1, microseconds=100))
>>> f
1209620.1001
>>> f == 20.1 + 0.0001 + 2 * 7 * 24 * 60 * 60 
True

>>> datetime2float("type error")(more...)

        def datetime2float(t):
    """  
    >>> datetime2float(datetime.timedelta(seconds=1))
    1.0
    
    >>> f = datetime2float(datetime.timedelta(weeks=2, seconds=20.1, microseconds=100))
    >>> f
    1209620.1001
    >>> f == 20.1 + 0.0001 + 2 * 7 * 24 * 60 * 60 
    True
    
    >>> datetime2float("type error")
    Traceback (most recent call last):
        ...
    TypeError: datetime2float() argument must be a timedelta instance.
    """
    if not isinstance(t, datetime.timedelta):
        raise TypeError("datetime2float() argument must be a timedelta instance.")

    # timedelta.total_seconds() is new in Python 2.7
    return (float(t.microseconds) + (t.seconds + t.days * 24 * 3600) * 1E6) / 1E6
        


src/d/j/django-processinfo-0.7.0/django_processinfo/admin.py   django-processinfo(Download)
from django_processinfo.models import SiteStatistics, ProcessInfo
from django_processinfo.utils.average import average
from django_processinfo.utils.human_time import timesince2, human_duration, \
    datetime2float
from django_processinfo.utils.proc_info import meminfo, uptime_infomation, \
            life_time_avg = 0
        else:
            life_time_values = [datetime2float(td) for td in life_time_values]
            life_time_min = min(life_time_values)
            life_time_max = max(life_time_values)

src/d/j/django-processinfo-HEAD/django_processinfo/admin.py   django-processinfo(Download)
from django_processinfo.models import SiteStatistics, ProcessInfo
from django_processinfo.utils.average import average
from django_processinfo.utils.human_time import timesince2, human_duration, \
    datetime2float
from django_processinfo.utils.proc_info import meminfo, uptime_infomation, \
            life_time_avg = 0
        else:
            life_time_values = [datetime2float(td) for td in life_time_values]
            life_time_min = min(life_time_values)
            life_time_max = max(life_time_values)