[Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973
Martin Langhoff
martin.langhoff at gmail.com
Tue Oct 2 16:35:57 EDT 2012
On Tue, Oct 2, 2012 at 3:51 PM, Martin Langhoff
<martin.langhoff at gmail.com> wrote:
> Works as pseudocode. But I took a quick look at the datetime docs and
> it is... horrible. We want to be doing math on the epoch (seconds
> since 1970).
>
> They refuse to document it properly, but the answer to the riddle is
>
> datetime.datetime.now().strftime('%s.%f')
Actually, the answer is to avoid datetime. It's fine for high level
work; when you care about times defined as epoch values, you
import time
now = time.time()
so the code snippet should be (untested):
boot_time = int(boot_time) # discard the float part
now = int(time.time())
cutoff = now - 24 * 60 * 60
if uptime is not None:
boot_time = now - uptime
cutoff = max(cutoff, boot_time)
m
--
martin.langhoff at gmail.com
martin at laptop.org -- Software Architect - OLPC
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff
More information about the Sugar-devel
mailing list