Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e329bff

Browse filesBrowse files
committed
Use shared RFC 3339 timestamp format string in storage.
1 parent 461b2fd commit e329bff
Copy full SHA for e329bff

File tree

Expand file treeCollapse file tree

4 files changed

+11
-8
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+11
-8
lines changed

‎gcloud/storage/blob.py

Copy file name to clipboardExpand all lines: gcloud/storage/blob.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
from gcloud.storage._helpers import _scalar_property
3535
from gcloud.storage import _implicit_environ
3636
from gcloud.storage.acl import ObjectACL
37+
from gcloud._helpers import _RFC3339_MICROS
3738

3839

3940
_API_ACCESS_ENDPOINT = 'https://storage.googleapis.com'
40-
_GOOGLE_TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
4141

4242

4343
class Blob(_PropertyMixin):
@@ -695,7 +695,7 @@ def time_deleted(self):
695695
"""
696696
value = self._properties.get('timeDeleted')
697697
if value is not None:
698-
return datetime.datetime.strptime(value, _GOOGLE_TIMESTAMP_FORMAT)
698+
return datetime.datetime.strptime(value, _RFC3339_MICROS)
699699

700700
@property
701701
def updated(self):
@@ -709,7 +709,7 @@ def updated(self):
709709
"""
710710
value = self._properties.get('updated')
711711
if value is not None:
712-
return datetime.datetime.strptime(value, _GOOGLE_TIMESTAMP_FORMAT)
712+
return datetime.datetime.strptime(value, _RFC3339_MICROS)
713713

714714

715715
class _UploadConfig(object):

‎gcloud/storage/bucket.py

Copy file name to clipboardExpand all lines: gcloud/storage/bucket.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from gcloud.storage.acl import DefaultObjectACL
4747
from gcloud.storage.iterator import Iterator
4848
from gcloud.storage.blob import Blob
49-
from gcloud.storage.blob import _GOOGLE_TIMESTAMP_FORMAT
49+
from gcloud._helpers import _RFC3339_MICROS
5050

5151

5252
class _BlobIterator(Iterator):
@@ -692,7 +692,7 @@ def time_created(self):
692692
"""
693693
value = self._properties.get('timeCreated')
694694
if value is not None:
695-
return datetime.datetime.strptime(value, _GOOGLE_TIMESTAMP_FORMAT)
695+
return datetime.datetime.strptime(value, _RFC3339_MICROS)
696696

697697
@property
698698
def versioning_enabled(self):

‎gcloud/storage/test_blob.py

Copy file name to clipboardExpand all lines: gcloud/storage/test_blob.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,11 +1041,12 @@ def test_storage_class(self):
10411041

10421042
def test_time_deleted(self):
10431043
import datetime
1044+
from gcloud._helpers import _RFC3339_MICROS
10441045
BLOB_NAME = 'blob-name'
10451046
connection = _Connection()
10461047
bucket = _Bucket(connection)
10471048
TIMESTAMP = datetime.datetime(2014, 11, 5, 20, 34, 37)
1048-
TIME_DELETED = TIMESTAMP.isoformat() + '.000Z'
1049+
TIME_DELETED = TIMESTAMP.strftime(_RFC3339_MICROS)
10491050
properties = {'timeDeleted': TIME_DELETED}
10501051
blob = self._makeOne(BLOB_NAME, bucket=bucket, properties=properties)
10511052
self.assertEqual(blob.time_deleted, TIMESTAMP)
@@ -1057,11 +1058,12 @@ def test_time_deleted_unset(self):
10571058

10581059
def test_updated(self):
10591060
import datetime
1061+
from gcloud._helpers import _RFC3339_MICROS
10601062
BLOB_NAME = 'blob-name'
10611063
connection = _Connection()
10621064
bucket = _Bucket(connection)
10631065
TIMESTAMP = datetime.datetime(2014, 11, 5, 20, 34, 37)
1064-
UPDATED = TIMESTAMP.isoformat() + '.000Z'
1066+
UPDATED = TIMESTAMP.strftime(_RFC3339_MICROS)
10651067
properties = {'updated': UPDATED}
10661068
blob = self._makeOne(BLOB_NAME, bucket=bucket, properties=properties)
10671069
self.assertEqual(blob.updated, TIMESTAMP)

‎gcloud/storage/test_bucket.py

Copy file name to clipboardExpand all lines: gcloud/storage/test_bucket.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,9 @@ def test_storage_class(self):
857857

858858
def test_time_created(self):
859859
import datetime
860+
from gcloud._helpers import _RFC3339_MICROS
860861
TIMESTAMP = datetime.datetime(2014, 11, 5, 20, 34, 37)
861-
TIME_CREATED = TIMESTAMP.isoformat() + '.000Z'
862+
TIME_CREATED = TIMESTAMP.strftime(_RFC3339_MICROS)
862863
properties = {'timeCreated': TIME_CREATED}
863864
bucket = self._makeOne(properties=properties)
864865
self.assertEqual(bucket.time_created, TIMESTAMP)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.