-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: corepriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
Description
gcloud._helpers has accumulated a collection of ~10 helper functions related to datetime handling. These could perhaps use a review to determine if they are all essential and maximally useful.
The particular situation in which this has come up is a proposal to update _datetime_to_rfc3339() to handle time zones as in the following module-private helper function appearing in #1691:
def _format_timestamp(timestamp):
"""Convert a datetime object to a string as required by the API.
:type timestamp: :class:`datetime.datetime`
:param timestamp: A datetime object.
:rtype: string
:returns: The formatted timestamp. For example:
``"2016-02-17T19:18:01.763000Z"``
"""
if timestamp.tzinfo is not None:
# Convert to UTC and remove the time zone info.
timestamp = timestamp.replace(tzinfo=None) - timestamp.utcoffset()
return timestamp.isoformat() + 'Z'
Metadata
Metadata
Assignees
Labels
api: corepriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.