Exemple #1
0
 def test_time_str01(self):
     """Converting a DateTimeType to string and back again should
        result in the same time.
        Update: actually, as we round the time to seconds on conversion,
        they will *NOT* be the same.
     """
     nn1 = timelib.utc_nowtime()
     #
     tzinfo = pytz.timezone('Europe/Amsterdam')
     timelib.set_local_timezone(tzinfo)
     nn2 = timelib.loc_nowtime()
     for nn in [nn1, nn2]:
         self.convert_test(nn)
Exemple #2
0
 def _set_update_time(self) -> str:
     """Set the ChemDB update time to now
     and return the current datetime as a string.
     """
     s = self._sess
     tt = s.query(TimeUpdate).first()
     if tt is None:
         # make a new record
         tt = TimeUpdate(id=99)
         s.add(tt)
         s.commit()
     else:
         # tt.dt = datetime.datetime.utcnow()
         tt.dt = timelib.utc_nowtime()
         s.merge(tt)
         s.commit()
     return self.get_update_time()
Exemple #3
0
 def setup_method(self) -> None:
     self.utctime = timelib.utc_nowtime()
     ams = pytz.timezone('Europe/Amsterdam')
     timelib.set_local_timezone(ams)
     self.loctime = timelib.loc_nowtime()
Exemple #4
0
 def setup_method(self) -> None:
     self.utctime = timelib.utc_nowtime()
Exemple #5
0
 def test_datetime_to_str01(self):
     """timelib.datetime_to_str() must raise a RuntimeError if the timezone is undefined."""
     timelib._tzinfo = None
     nn1 = timelib.utc_nowtime()
     with pytest.raises(RuntimeError):
         timelib.datetime_to_str(nn1, in_local_tz=True)