diff weather_server/types.py @ 11:52ef21607b31

server: Create endpoint to get some recent readings.
author Paul Fisher <paul@pfish.zone>
date Sun, 06 Oct 2019 13:11:11 -0400
parents efe7a1eff167
children beb42c835c52
line wrap: on
line diff
--- a/weather_server/types.py	Sun Sep 29 20:42:11 2019 -0400
+++ b/weather_server/types.py	Sun Oct 06 13:11:11 2019 -0400
@@ -5,7 +5,8 @@
 import typing as t
 
 import attr
-import pytz
+
+from . import common
 
 
 def c_to_f(c: float) -> float:
@@ -55,14 +56,10 @@
 
     @classmethod
     def from_now(cls, **kwargs) -> 'Reading':
-        return cls(ingest_time=_utc_now(), **kwargs)
+        return cls(ingest_time=common.utc_now(), **kwargs)
 
     @property
     def _gamma(self) -> float:
         return (
             math.log(self.rh_pct / 100) +
             _MAGNUS_B * self.temp_c / (_MAGNUS_C + self.temp_c))
-
-
-def _utc_now():
-    return datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)