I'm using Go with SDK version 1.9.37
I'm seeing something odd when testing the datastore with entities which have a time.Time field. I create the time with time.Now().UTC().Truncate(time.Millisecond), and then save it. When I retrieve the entity, the time is correct, but the time.Location has changed. from UTC to CEST. My local timezone is CEST, but all times used in my code are UTC.
Is this a know behaviour that the datastore modifies the Location? If so, is there a way to prevent it?
type Container struct {
Value time.Time
}
to_store := Container{ time.Now().UTC().Truncate(time.Millisecond) }
fmt.Println(to_store.Value.Location())
key := datastore.NewKey(ctx, "Container", "unique_string", 0, nil)
_, err := datastore.Put(ctx, key, &to_store)
if err != nil {
// handle error
return
}
var retrieved Container
err = datastore.Get(ctx, key, &b)
if err != nil {
// handle error
return
}
fmt.Println(retrieved.Value.Location())