## Add functions and events for filling in timestamped fields
# loaded
method.set_key = event.download.inserted_new, !time_stamp,\
    "d.custom.set=tm_loaded,$cat=$system.time= ; d.save_resume="

# started
method.insert = pyro._tm_started.now, simple|private,\
    "d.custom.set=tm_started,$cat=$system.time= ; d.save_resume="
method.set_key = event.download.resumed, !time_stamp,\
    "branch=d.custom=tm_started,false=,pyro._tm_started.now="

# completed
method.insert = pyro._tm_completed.now, simple|private,\
    "d.custom.set=tm_completed,$cat=$system.time= ; d.save_resume="
method.set_key = event.download.finished, !time_stamp,\
    "pyro._tm_completed.now="
method.set_key = event.download.hash_done, !time_stamp,\
    "branch=\"and={d.complete=,not=$d.custom=tm_completed}\", pyro._tm_completed.now="

# active
method.insert = d.last_xfer.is_active, simple,\
    "or={pyro._last_xfer_check_min_rate=$d.up.rate=,pyro._last_xfer_check_min_rate=$d.down.rate=}"
method.insert = d.timestamp.last_xfer, simple, "if=$d.last_xfer.is_active=,$cat=$system.time=,$d.custom=last_xfer"
schedule2 = pyro_update_last_xfer, 33, 17,\
    "d.multicall2=active,\"branch=$d.last_xfer.is_active=,pyro._last_xfer_update=\""

# last_xfer
method.insert.value = pyro.last_xfer.min_rate, 5000
method.insert = pyro._last_xfer_check_min_rate, simple|private,\
    "greater=argument.0=,pyro.last_xfer.min_rate="
method.insert = pyro._last_xfer_update, simple|private,\
    "d.custom.set=last_xfer,$cat=$system.time= ; branch=argument.0=,d.save_resume="
schedule2 = pyro_update_last_xfer, 33, 17,\
    "d.multicall2=active,\"branch=$d.last_xfer.is_active=,pyro._last_xfer_update=\""
