How to define start and end times in python
Question: I am using the code

    
    
    def run_periodically(start, end, interval, func):
        event_time = start
        while event_time < end:
            s.enterabs(event_time, 0, func, ())
            event_time += interval + random(-5, 45)
        s.run()
    
        run_periodically(time()+5, time()+1000000, 10, getData)
    

Now If I wanted to define the start time as 22.00 how is this formatted in
python?

e.g. I would change the code to

    
    
    starttime = #?#
    
    run_periodically(starttime(), time()+1000000, 10, getData)
    

What is the standard time formatting used to make this work?


Answer: The Python time() related functions take the number of seconds since a
particular date (depending on your os). You can convert that from the
`datetime` types using `datetime.time()`

    
    
    import datetime
    timestamp = datetime.datetime(2013, 6, 4, 6, 18, 1).time()
    

That makes `timestamp` usable for `run_periodically`.

You can also go the other way by using `datetime.fromtimestamp(time.time())`.
All this and more detailed info can be found in the [module
documentation](http://docs.python.org/2/library/datetime.html).

