def test_rfc3339_to_datetime_bad_format_has_timezone( self ): # currently this function only handles UTC. Remove this test if # updated to be more flexible s = "2015-08-06T14:40:56.123456789+04:00" expected = None actual = scalyr_util.rfc3339_to_datetime( s ) self.assertEquals( expected, actual )
def split_datetime_from_line( self, line ): """Docker timestamps are in RFC3339 format: 2015-08-03T09:12:43.143757463Z, with everything up to the first space being the timestamp. """ log_line = line dt = datetime.datetime.utcnow() pos = line.find( ' ' ) if pos > 0: dt = scalyr_util.rfc3339_to_datetime( line[0:pos] ) log_line = line[pos+1:] return (dt, log_line)
def test_rfc3339_to_datetime_bad_format_date_and_time_separator( self ): s = "2015-08-06 14:40:56.123456789Z" expected = None actual = scalyr_util.rfc3339_to_datetime( s ) self.assertEquals( expected, actual )
def test_rfc3339_to_datetime_truncated_nano( self ): s = "2015-08-06T14:40:56.123456789Z" expected = datetime.datetime( 2015, 8, 6, 14, 40, 56, 123456 ) actual = scalyr_util.rfc3339_to_datetime( s ) self.assertEquals( expected, actual )
def test_rfc3339_to_datetime(self): s = "2015-08-06T14:40:56.123456Z" expected = datetime.datetime(2015, 8, 6, 14, 40, 56, 123456) actual = scalyr_util.rfc3339_to_datetime(s) self.assertEquals(expected, actual)
def test_rfc3339_to_datetime_bad_format_date_and_time_separator(self): s = "2015-08-06 14:40:56.123456789Z" expected = None actual = scalyr_util.rfc3339_to_datetime(s) self.assertEquals(expected, actual)