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

DISCUSSION: Should deserialized timestamps have a timezone? #279

Closed
dhermes opened this issue Oct 21, 2014 · 5 comments
Closed

DISCUSSION: Should deserialized timestamps have a timezone? #279

dhermes opened this issue Oct 21, 2014 · 5 comments
Assignees
Labels
api: datastore Issues related to the Datastore API. type: question Request for information or clarification. Not an issue.

Comments

@dhermes
Copy link
Contributor

dhermes commented Oct 21, 2014

Also relates to #278.

It's not immediately clear how we should support this.

The fact that we support datetime.datetime objects with timezones makes the seralize/deserialize operation potentially a function other than the identity.

For example

>>> from gcloud.datastore.datastore_v1_pb2 import Value
>>> value_pb = Value()
>>> import datetime
>>> import pytz
>>> timestamp = datetime.datetime.utcnow().replace(tzinfo=pytz.timezone('CET'))
>>> timestamp
datetime.datetime(2014, 10, 21, 23, 49, 31, 816554, tzinfo=<DstTzInfo 'CET' CET+1:00:00 STD>)
>>> from gcloud.datastore._helpers import _set_protobuf_value
>>> _set_protobuf_value(value_pb, timestamp)
>>> from gcloud.datastore._helpers import _get_value_from_value_pb
>>> _get_value_from_value_pb(value_pb)
datetime.datetime(2014, 10, 21, 22, 49, 31, 816554, tzinfo=<UTC>)

I realized this while doing a before/after dictionary comparison in the regression test

dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 21, 2014
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 22, 2014
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 22, 2014
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 22, 2014
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 23, 2014
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 23, 2014
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 23, 2014
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 23, 2014
dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 26, 2014
@pcostell
Copy link
Contributor

As a point of reference, NDB supports datetime but doesn't allow any timezone set and assumes utc. This somewhat solves the problem because it only allows offset-naive datetimes.

@dhermes
Copy link
Contributor Author

dhermes commented Oct 27, 2014

I am in favor of that approach.

We could avoid throwing away the good work by putting the offset -> naive conversion into datastore.helpers or by documenting the process in a place people will see.

This solves equality within the datetime.datetime type but we need a Property abstraction to map the difference between time.time, datetime.date and datetime.datetime.

dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 27, 2014
@tseaver
Copy link
Contributor

tseaver commented Oct 27, 2014

When marshalling naive datetime values to a protobuf value, we already convert them to microseconds (silently) as though they were explicitly UTC. When marshalling zoned datetime values, we first convert to UTC, and then compute the timestamp as microsecons.

The real question is what we should do when unmarshalling a microsecond timestamp from a protobuf: we know it must be UTC, so #181 explicitly adds the UTC zone to it before setting it into the entity dict (rather than leaving it ambiguously naive).

While we could marshall a 'datetime.date' to a timestamp (assuming midnight UTC), there is no way to unmarshall a microsecond timestamp as anything other than a 'datetime.datetime' instance. Given that it would be confusing to marshal a as one type but unmarshall another, I'm not sure we should support passing in 'datetime.date' (principle of least surprise).

dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 27, 2014
@dhermes
Copy link
Contributor Author

dhermes commented Oct 27, 2014

@tseaver I totally agree. This is too low-level to provide the needed information (i.e. an underlying type) as is done in some higher level libraries:
https://cloud.google.com/appengine/docs/python/ndb/properties#Date_and_Time

However, by requiring naive timestamps are passed in, we can at least guarantee the marshall / unmarshall operations are true inverse functions.

That's why I suggested decoupling the tz -> naive part into it's own helper method.

dhermes added a commit to dhermes/google-cloud-python that referenced this issue Oct 27, 2014
@tseaver tseaver added api: datastore Issues related to the Datastore API. type: question Request for information or clarification. Not an issue. labels Oct 28, 2014
@dhermes
Copy link
Contributor Author

dhermes commented Jan 27, 2015

Closing this out in light of closing comment of #278

@dhermes dhermes closed this as completed Jan 27, 2015
@jgeewax jgeewax modified the milestone: Datastore Stable Jan 30, 2015
urshala pushed a commit to urshala/google-cloud-python that referenced this issue Jan 17, 2020
atulep pushed a commit that referenced this issue Apr 3, 2023
- [ ] Regenerate this pull request now.

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency

committer: busunkim96@
PiperOrigin-RevId: 406468269

Source-Link: googleapis/googleapis@83d81b0

Source-Link: googleapis/googleapis-gen@2ff001f
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
atulep pushed a commit that referenced this issue Apr 6, 2023
- [ ] Regenerate this pull request now.

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency

committer: busunkim96@
PiperOrigin-RevId: 406468269

Source-Link: googleapis/googleapis@83d81b0

Source-Link: googleapis/googleapis-gen@2ff001f
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
atulep pushed a commit that referenced this issue Apr 6, 2023
- [ ] Regenerate this pull request now.

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency

committer: busunkim96@
PiperOrigin-RevId: 406468269

Source-Link: googleapis/googleapis@83d81b0

Source-Link: googleapis/googleapis-gen@2ff001f
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
atulep pushed a commit that referenced this issue Apr 18, 2023
- [ ] Regenerate this pull request now.

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency

committer: busunkim96@
PiperOrigin-RevId: 406468269

Source-Link: googleapis/googleapis@83d81b0

Source-Link: googleapis/googleapis-gen@2ff001f
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
parthea added a commit that referenced this issue Jun 4, 2023
* chore(deps): update all dependencies

* revert

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Jun 4, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Jun 4, 2023
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Jun 4, 2023
Source-Link: googleapis/synthtool@69fabae
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:562802bfac02e012a6ac34eda282f81d06e77326b82a32d7bbb1369ff552b387
parthea pushed a commit that referenced this issue Jun 4, 2023
- [x] Regenerate this pull request now.

chore: use gapic-generator-python 0.62.1

docs: added more clarification around what event_time means on a v1 finding

fix: resolve DuplicateCredentialArgs error when using credentials_file

committer: parthea
PiperOrigin-RevId: 425964861

Source-Link: googleapis/googleapis@84b1a5a

Source-Link: googleapis/googleapis-gen@4fb761b
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZiNzYxYmJkODUwNmFjMTU2ZjQ5YmFjNWYxODMwNmFhOGViM2FhOCJ9
parthea pushed a commit that referenced this issue Jun 4, 2023
Source-Link: googleapis/synthtool@993985f
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd
parthea added a commit that referenced this issue Jul 6, 2023
* chore(deps): update all dependencies

* revert change for pinned version

Co-authored-by: Anthonios Partheniou <partheniou@google.com>
parthea added a commit that referenced this issue Aug 15, 2023
* chore: allow releases on previous majors

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Aug 15, 2023
Source-Link: https://github.com/googleapis/synthtool/commit/30bd01b4ab78bf1b2a425816e15b3e7e090993dd
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:9bc5fa3b62b091f60614c08a7fb4fd1d3e1678e326f34dd66ce1eefb5dc3267b
parthea added a commit that referenced this issue Sep 20, 2023
* chore(deps): update all dependencies

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* revert

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
vchudnov-g pushed a commit that referenced this issue Sep 20, 2023
reverts previous commit for preventing normalization of versioning
parthea pushed a commit that referenced this issue Sep 22, 2023
Source-Link: googleapis/synthtool@7197a00
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:c43f1d918bcf817d337aa29ff833439494a158a0831508fda4ec75dc4c0d0320

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Sep 22, 2023
- [ ] Regenerate this pull request now.

feat: allow customer to enroll a datasource programmatically 

docs: improvements to various message and field descriptions 

feat: add api key support

chore: use gapic-generator-python 0.62.1

fix: resolve DuplicateCredentialArgs error when using credentials_file

docs: preserve hyperlinks with hyphens

committer: parthea
PiperOrigin-RevId: 425964861

Source-Link: googleapis/googleapis@84b1a5a

Source-Link: googleapis/googleapis-gen@4fb761b
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNGZiNzYxYmJkODUwNmFjMTU2ZjQ5YmFjNWYxODMwNmFhOGViM2FhOCJ9
parthea pushed a commit that referenced this issue Sep 22, 2023
Source-Link: googleapis/synthtool@694118b
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:ec49167c606648a063d1222220b48119c912562849a0528f35bfb592a9f72737

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Sep 22, 2023
Source-Link: https://github.com/googleapis/synthtool/commit/cb960373d12d20f8dc38beee2bf884d49627165e
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:2d816f26f728ac8b24248741e7d4c461c09764ef9f7be3684d557c9632e46dbd
parthea pushed a commit that referenced this issue Sep 22, 2023
…279)

Source-Link: googleapis/synthtool@95d9289
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:c8878270182edaab99f2927969d4f700c3af265accd472c3425deedff2b7fd93

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Sep 22, 2023
Source-Link: googleapis/synthtool@993985f
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:1894490910e891a385484514b22eb5133578897eb5b3c380e6d8ad475c6647cd
parthea pushed a commit that referenced this issue Sep 22, 2023
Source-Link: googleapis/synthtool@ca87909
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:6162c384d685c5fe22521d3f37f6fc732bf99a085f6d47b677dbcae97fc21392
parthea added a commit that referenced this issue Oct 21, 2023
Source-Link: googleapis/synthtool@5c0fa62
Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:0ffe3bdd6c7159692df5f7744da74e5ef19966288a6bf76023e8e04e0c424d7d

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
parthea pushed a commit that referenced this issue Oct 21, 2023
Source-Link: googleapis/synthtool@1b71c10
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:00c9d764fd1cd56265f12a5ef4b99a0c9e87cf261018099141e2ca5158890416

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Oct 21, 2023
* chore(deps): update all dependencies

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea added a commit that referenced this issue Oct 21, 2023
…279)

* chore: add default_version and codeowner_team to .repo-metadata.json

* update default_version and codeowner_team
parthea pushed a commit that referenced this issue Oct 21, 2023
* chore: put Locations mixin back

PiperOrigin-RevId: 477369320

Source-Link: googleapis/googleapis@6954c4d

Source-Link: googleapis/googleapis-gen@81e5272
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFlNTI3MjY3MWJkMWM1YzhhYzE1YTQ0YmQyNTkyMmYwYjkzZWFlNiJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this issue Oct 21, 2023
🤖 I have created a release \*beep\* \*boop\*
---
### [2.5.2](https://github.com/googleapis/python-automl/compare/v2.5.1...v2.5.2) (2021-11-01)


### Bug Fixes

* **deps:** drop packaging dependency ([e50d4c9](https://github.com/googleapis/python-automl/commit/e50d4c928601f6a32b22dcd36338e820254451d4))
* **deps:** require google-api-core >= 1.28.0 ([e50d4c9](https://github.com/googleapis/python-automl/commit/e50d4c928601f6a32b22dcd36338e820254451d4))


### Documentation

* list oneofs in docstring ([e50d4c9](https://github.com/googleapis/python-automl/commit/e50d4c928601f6a32b22dcd36338e820254451d4))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
parthea pushed a commit that referenced this issue Oct 21, 2023
Source-Link: googleapis/synthtool@453a5d9
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32
parthea pushed a commit that referenced this issue Oct 22, 2023
…279)

Source-Link: https://github.com/googleapis/synthtool/commit/395d53adeeacfca00b73abf197f65f3c17c8f1e9
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:6c1cbc75c74b8bdd71dada2fa1677e9d6d78a889e9a70ee75b93d1d0543f96e1
parthea pushed a commit that referenced this issue Oct 22, 2023
- [ ] Regenerate this pull request now.

docs: list oneofs in docstring
fix(deps): require google-api-core >= 1.28.0
fix(deps): drop packaging dependency

committer: busunkim96@
PiperOrigin-RevId: 406468269

Source-Link: googleapis/googleapis@83d81b0

Source-Link: googleapis/googleapis-gen@2ff001f
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMmZmMDAxZmJhY2I5ZTc3ZTcxZDczNGRlNWY5NTVjMDVmZGFlODUyNiJ9
parthea pushed a commit that referenced this issue Oct 31, 2023
Source-Link: googleapis/synthtool@d52e638
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:4f9b3b106ad0beafc2c8a415e3f62c1a0cc23cabea115dbe841b848f581cfe99

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants