Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move TimestampNanoSeconds to api_core #4979

Merged
merged 3 commits into from
Mar 9, 2018

Conversation

chemelnucfin
Copy link
Contributor

Closes #4829

@chemelnucfin chemelnucfin added api: core api: spanner Issues related to the Spanner API. type: process A process-related concern. May include testing, release, or the like. labels Feb 28, 2018
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 28, 2018
Copy link
Contributor

@theacodes theacodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the changes to spanner in a separate PR?

nanosecond=nanos, tzinfo=UTC)


class _UTC(datetime.tzinfo):

This comment was marked as spam.

nanos = kw.pop('nanosecond', 0)
if nanos > 0:
if 'microsecond' in kw:
raise TypeError(

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

__slots__ = ('_nanosecond',)

# pylint: disable=arguments-differ
def __new__(cls, *args, **kw):

This comment was marked as spam.

This comment was marked as spam.

return self._nanosecond

def rfc3339(self):
"""RFC 3339-compliant timestamp.

This comment was marked as spam.

def rfc3339(self):
"""RFC 3339-compliant timestamp.

:rtype: str

This comment was marked as spam.

if self._nanosecond == 0:
return to_rfc3339(self)
nanos = str(self._nanosecond).rstrip('0')
return '%s.%sZ' % (self.strftime(_RFC3339_NO_FRACTION), nanos)

This comment was marked as spam.

@@ -13,6 +13,7 @@
# limitations under the License.

import datetime
import unittest

This comment was marked as spam.

@chemelnucfin chemelnucfin force-pushed the timestamp_to_api_core branch 2 times, most recently from d386fd0 to 414f86a Compare March 1, 2018 02:26
Copy link
Contributor

@theacodes theacodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loooking pretty close, just a few more nits.



def test_timestampwithnanos_from_rfc3339_wo_fraction():
from google.api_core import datetime_helpers

This comment was marked as spam.

def test_timestampwithnanos_from_rfc3339_wo_fraction():
from google.api_core import datetime_helpers

klass = datetime_helpers.TimestampWithNanoseconds

This comment was marked as spam.

@@ -179,3 +179,71 @@ def to_rfc3339(value, ignore_zone=True):
value = value.replace(tzinfo=None) - value.utcoffset()

return value.strftime(_RFC3339_MICROS)


class TimestampWithNanoseconds(datetime.datetime):

This comment was marked as spam.

@chemelnucfin chemelnucfin merged commit ed3c300 into googleapis:master Mar 9, 2018
@chemelnucfin chemelnucfin deleted the timestamp_to_api_core branch March 9, 2018 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: core api: spanner Issues related to the Spanner API. cla: yes This human has signed the Contributor License Agreement. type: process A process-related concern. May include testing, release, or the like.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants