Thanks for sharing your observations here.
In production, Datastore does not modify the *Location* of the *Time*
value. I used a variation of the following code in my request handler to
verify this:
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())
Both *Location* values were the same. What I did notice however is that
the Datastore viewer in the Developers Console shows the time in the
timezone of the browser viewing it. I suppose this is to be expected much
like most browser-based UIs.
If you see the above code NOT showing the same *Location* in either
production or developement, please file a defect report on the App Engine
public issue tracker <https://code.google.com/p/googleappengine/issues/list>
as the Datastore documentation makes no mention of modifying a *time*'s
*Location*. This would therefore constitute a platform issue if it were
present.
Hope this helps!
On Friday, June 17, 2016 at 8:10:22 AM UTC-4, JohnGB wrote:
>
> 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?
>
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/a69131e8-6339-41fd-8fa4-90f3911f41e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.