Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion google/cloud/spanner_v1/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _make_value_pb(value):
if isinstance(value, datetime_helpers.DatetimeWithNanoseconds):
return Value(string_value=value.rfc3339())
if isinstance(value, datetime.datetime):
return Value(string_value=_datetime_to_rfc3339(value))
return Value(string_value=_datetime_to_rfc3339(value, ignore_zone=False))
if isinstance(value, datetime.date):
return Value(string_value=value.isoformat())
if isinstance(value, six.binary_type):
Expand Down
14 changes: 13 additions & 1 deletion tests/unit/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ def test_w_timestamp_w_nanos(self):
value_pb = self._callFUT(when)
self.assertIsInstance(value_pb, Value)
self.assertEqual(value_pb.string_value, when.rfc3339())

def test_w_listvalue(self):
from google.protobuf.struct_pb2 import Value
from google.cloud.spanner_v1._helpers import _make_list_value_pb
Expand All @@ -215,6 +214,19 @@ def test_w_datetime(self):
self.assertIsInstance(value_pb, Value)
self.assertEqual(value_pb.string_value, datetime_helpers.to_rfc3339(now))

def test_w_timestamp_w_tz(self):
import datetime
import pytz
from google.protobuf.struct_pb2 import Value

when = datetime.datetime(
2021, 2, 8, 0, 0, 0, tzinfo=pytz.timezone("US/Mountain")
)
value_pb = self._callFUT(when)
self.assertIsInstance(value_pb, Value)
self.assertEqual(value_pb.string_value, "2021-02-08T07:00:00.000000Z")


def test_w_numeric(self):
import decimal
from google.protobuf.struct_pb2 import Value
Expand Down