For testing purposes, I have deployed the following Firebase Cloud Function. When the function gets called, it adds a document to my Firestore collection with two fields containing two datetimes.
@https_fn.on_call(region='europe-west1', vpc_connector='connector1', vpc_connector_egress_settings=options.VpcEgressSetting('ALL_TRAFFIC'))
def testing(req: https_fn.CallableRequest):
firestore_client: google.cloud.firestore.Client = firestore.client()
visit_collection = firestore_client.collection('visits')
visit_collection.add(
{
'test1': datetime.now().astimezone(),
'test2': datetime.now().replace(hour=0, minute=0, second=0, microsecond=0).astimezone(),
},
'test'
)
When looking at the contents of the document in Cloud Firestore in the Firebase Console, what I would expect for the values of the fields in my document is (if it would be 19:50):
test1: 23 March 2024 at 19:50:00 UTC+1
test2: 23 March 2024 at 00:00:00 UTC+1
Instead, what I see in the document is:
test1: 23 March 2024 at 19:50:00 UTC+1
test2: 23 March 2024 at 01:00:00 UTC+1
from datetime import UTC, and use.astimezone(UTC).astimezone()has exactly the same output. It's very strange what happens inside the Cloud Function. When I run the code inside the Cloud Function locally on my laptop, the result is as expected (00:00 UTC+1 instead of 01:00 UTC+1).