コード例 #1
0
 def _doc_to_total_result(self, doc, start, end):
     output = {
         'begin': self._normalize_time(doc.get('start', start)),
         'end': self._normalize_time(doc.get('end', end)),
         'qty': doc['sum_qty']['value'],
         'rate': doc['sum_price']['value'],
     }
     # Means we had a composite aggregation
     if 'key' in doc.keys():
         for key, value in doc['key'].items():
             if key == 'begin' or key == 'end':
                 # Elasticsearch returns ts in milliseconds
                 value = tzutils.dt_from_ts(value // 1000)
             output[key] = value
     return output
コード例 #2
0
ファイル: test_tz.py プロジェクト: wanghuiict/cloudkitty
 def test_cloudkitty_dt_from_ts_local_tz(self):
     ts = 1569902400
     timezone = tz.gettz('Europe/Paris')
     dt = datetime.datetime(2019, 10, 1, 6, tzinfo=timezone)
     with mock.patch.object(tzutils, '_LOCAL_TZ', new=timezone):
         self.assertEqual(dt, tzutils.dt_from_ts(ts))
コード例 #3
0
ファイル: test_tz.py プロジェクト: wanghuiict/cloudkitty
 def test_cloudkitty_dt_from_ts_as_utc(self):
     ts = 1569902400
     dt = datetime.datetime(2019, 10, 1, 4, tzinfo=tz.tzutc())
     self.assertEqual(dt, tzutils.dt_from_ts(ts, as_utc=True))