comparison weather_server/server.py @ 43:1a69004d8e5a v0.2.1

Remove improper, broken use of ZoneInfo.localize.
author Paul Fisher <paul@pfish.zone>
date Tue, 01 Apr 2025 16:29:09 -0400
parents b77c8e7d2742
children
comparison
equal deleted inserted replaced
42:d63ed60a41c7 43:1a69004d8e5a
53 except KeyError: 53 except KeyError:
54 flask.abort(404) 54 flask.abort(404)
55 last_reading = loc.latest() 55 last_reading = loc.latest()
56 if last_reading: 56 if last_reading:
57 tz = loc.timezone() 57 tz = loc.timezone()
58 date = tz.normalize(last_reading.sample_time.astimezone(tz)) 58 date = last_reading.sample_time.astimezone(tz)
59 else: 59 else:
60 date = None 60 date = None
61 now = datetime.datetime.now(tz=datetime.UTC) 61 now = datetime.datetime.now(tz=datetime.UTC)
62 diff = (now - date) if date else None 62 diff = (now - date) if date else None
63 is_recent = diff and diff < datetime.timedelta(hours=12) 63 is_recent = diff and diff < datetime.timedelta(hours=12)