Ver código fonte

PR1123 [aws] s3datetime_to_timestamp parse timestamp with Z(minio.io) (#1123)

* fix(aws): s3datetime_to_timestamp parse timestamp with Z(minio)

* fix(aws): test_s3datetime_to_timestamp()

* fix(aws): test_s3datetime_to_timestamp()

Co-authored-by: Ilya Makarov <makarov_ia@nlmk.com>
e11it 5 anos atrás
pai
commit
acbb4d77e0

+ 1 - 1
desktop/libs/aws/src/aws/s3/__init__.py

@@ -137,5 +137,5 @@ def s3datetime_to_timestamp(datetime):
     assert datetime[-4:] == ' GMT', 'Time [%s] is not in GMT.' % datetime
   except ValueError:
     stripped = time.strptime(datetime[:-5], '%Y-%m-%dT%H:%M:%S')
-    assert datetime[-5:] == '.000Z', 'Time [%s] is not in GMT.' % datetime
+    assert datetime[-1:] == 'Z' and datetime[-5:-4] == '.', 'Time [%s] is not in GMT.' % datetime
   return int(calendar.timegm(stripped))

+ 1 - 1
desktop/libs/aws/src/aws/s3/s3_test.py

@@ -65,11 +65,11 @@ def test_s3datetime_to_timestamp():
   f = s3.s3datetime_to_timestamp
   eq_(1424983327, f('Thu, 26 Feb 2015 20:42:07 GMT'))
   eq_(1424983327, f('2015-02-26T20:42:07.000Z'))
+  eq_(1424983327, f('2015-02-26T20:42:07.040Z'))
 
   assert_raises(ValueError, f, '2/26/2015 20:42:07')
 
   assert_raises(AssertionError, f, 'Thu, 26 Feb 2015 20:42:07 PDT')
-  assert_raises(AssertionError, f, '2015-02-26T20:42:07.040Z')
 
 
 def test_get_default_region():