示例#1
0
    def test_mktime_with_tz(self):
        # see https://en.wikipedia.org/wiki/File:1000000000seconds.jpg
        dt = datetime(2001, 9, 9, 1, 46, 40, 0, tzinfo=pytz.utc)
        assert int(common.mktime(dt)) == 1000000000

        dt = datetime(2001, 9, 9, 1, 46, 40, 0, tzinfo=pytz.timezone("EST"))
        assert int(common.mktime(dt)) == 1000000000 + (5 * 60 * 60)  # EST is UTC-5
示例#2
0
    def test_mktime_millis_with_tz(self):
        # see https://en.wikipedia.org/wiki/File:1000000000
        dt = datetime(2001, 9, 9, 1, 46, 40, 0, tzinfo=pytz.utc)
        self.assertEquals(1000000000, int(common.mktime(dt, millis=True) / 1000))

        dt = datetime(2001, 9, 9, 1, 46, 40, 0, tzinfo=pytz.timezone('EST'))
        self.assertEquals(1000000000 + (5 * 60 * 60), int(common.mktime(dt, millis=True)) / 1000)  # EST is UTC-5
示例#3
0
    def test_mktime_with_tz(self):
        # see https://en.wikipedia.org/wiki/File:1000000000seconds.jpg
        dt = datetime(2001, 9, 9, 1, 46, 40, 0, tzinfo=pytz.utc)
        self.assertEqual(1000000000, int(common.mktime(dt)))

        dt = datetime(2001, 9, 9, 1, 46, 40, 0, tzinfo=pytz.timezone('EST'))
        self.assertEqual(1000000000 + (5 * 60 * 60),
                         int(common.mktime(dt)))  # EST is UTC-5
示例#4
0
    def test_mktime_millis_with_tz(self):
        # see https://en.wikipedia.org/wiki/File:1000000000
        dt = datetime(2001, 9, 9, 1, 46, 40, 0, tzinfo=pytz.utc)
        assert int(common.mktime(dt, millis=True) / 1000) == 1000000000

        dt = datetime(2001, 9, 9, 1, 46, 40, 0, tzinfo=pytz.timezone("EST"))
        assert int(common.mktime(dt, millis=True)) / 1000 == 1000000000 + (
            5 * 60 * 60)  # EST is UTC-5
def get_kinesis_events(stream_name, shard_id, max_results=10, env=None):
    env = aws_stack.get_environment(env)
    records = aws_stack.kinesis_get_latest_records(stream_name, shard_id, count=max_results, env=env)
    for r in records:
        r['ApproximateArrivalTimestamp'] = mktime(r['ApproximateArrivalTimestamp'])
    result = {
        'events': records
    }
    return result
示例#6
0
文件: infra.py 项目: bbc/localstack
def get_kinesis_events(stream_name, shard_id, max_results=10, env=None):
    env = aws_stack.get_environment(env)
    records = aws_stack.kinesis_get_latest_records(stream_name, shard_id, count=max_results, env=env)
    for r in records:
        r['ApproximateArrivalTimestamp'] = mktime(r['ApproximateArrivalTimestamp'])
    result = {
        'events': records
    }
    return result
示例#7
0
def get_kinesis_events(stream_name, shard_id, max_results=10, env=None):
    records = []
    try:
        env = aws_stack.get_environment(env)
        records = aws_stack.kinesis_get_latest_records(
            stream_name, shard_id, count=max_results, env=env
        )
        for r in records:
            r["ApproximateArrivalTimestamp"] = mktime(r["ApproximateArrivalTimestamp"])
    except Exception:
        pass
    result = {"events": records}
    return result
示例#8
0
 def test_mktime(self):
     env = common.mktime(datetime(2010, 3, 20, 7, 24, 00, 0), True)
     self.assertEqual(env, 1269069840.0)
示例#9
0
 def test_now(self):
     env = common.now()
     test = common.mktime(datetime.now())
     self.assertEqual(env, test)
示例#10
0
 def test_mktime_millis(self):
     now = common.mktime(datetime.now(), millis=True)
     assert int(time.time()) == int(now / 1000)
示例#11
0
 def test_mktime(self):
     now = common.mktime(datetime.now())
     assert int(now) == int(time.time())
示例#12
0
 def test_mktime_millis(self):
     now = common.mktime(datetime.now(), millis=True)
     self.assertEquals(int(time.time()), int(now / 1000))
示例#13
0
 def test_mktime(self):
     now = common.mktime(datetime.now())
     self.assertEquals(int(time.time()), int(now))