From: Peter Müller Date: Thu, 29 Oct 2020 14:36:46 +0000 (-0700) Subject: location.in: do not confuse UTC with local time zones X-Git-Tag: 0.9.5~92 X-Git-Url: http://git.ipfire.org/?p=location%2Flibloc.git;a=commitdiff_plain;h=60c1ac0307312614bd6980d30b44bb59b5a6ab6e location.in: do not confuse UTC with local time zones Signed-off-by: Peter Müller --- diff --git a/src/python/location.in b/src/python/location.in index 070640c..0d09210 100644 --- a/src/python/location.in +++ b/src/python/location.in @@ -398,10 +398,7 @@ class CLI(object): def handle_update(self, db, ns): if ns.cron and db: - now = datetime.datetime.utcnow() - - # Parse the database timestamp - t = datetime.datetime.utcfromtimestamp(db.created_at) + now = time.time() if ns.cron == "daily": delta = datetime.timedelta(days=1) @@ -410,11 +407,12 @@ class CLI(object): elif ns.cron == "monthly": delta = datetime.timedelta(days=30) + delta = delta.total_seconds() + # Check if the database has recently been updated - if t >= (now - delta): + if db.created_at >= (now - delta): log.info( - _("The database has been updated recently (%s)") % \ - format_timedelta(now - t), + _("The database has been updated recently"), ) return 3