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
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
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
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
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
def test_mktime(self): env = common.mktime(datetime(2010, 3, 20, 7, 24, 00, 0), True) self.assertEqual(env, 1269069840.0)
def test_now(self): env = common.now() test = common.mktime(datetime.now()) self.assertEqual(env, test)
def test_mktime_millis(self): now = common.mktime(datetime.now(), millis=True) assert int(time.time()) == int(now / 1000)
def test_mktime(self): now = common.mktime(datetime.now()) assert int(now) == int(time.time())
def test_mktime_millis(self): now = common.mktime(datetime.now(), millis=True) self.assertEquals(int(time.time()), int(now / 1000))
def test_mktime(self): now = common.mktime(datetime.now()) self.assertEquals(int(time.time()), int(now))