| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package datastore | 5 package datastore |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "fmt" | 9 "fmt" |
| 10 "math" | 10 "math" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 case string: | 199 case string: |
| 200 return PTString, nil | 200 return PTString, nil |
| 201 case Key: | 201 case Key: |
| 202 // TODO(riannucci): Check key for validity in its own namespace? | 202 // TODO(riannucci): Check key for validity in its own namespace? |
| 203 return PTKey, nil | 203 return PTKey, nil |
| 204 case time.Time: | 204 case time.Time: |
| 205 err := error(nil) | 205 err := error(nil) |
| 206 if checkValid && (x.Before(minTime) || x.After(maxTime)) { | 206 if checkValid && (x.Before(minTime) || x.After(maxTime)) { |
| 207 err = errors.New("time value out of range") | 207 err = errors.New("time value out of range") |
| 208 } | 208 } |
| 209 » » if checkValid && x.Location() != time.UTC { | 209 » » if checkValid && !x.Equal(x.In(time.UTC)) { |
| 210 err = fmt.Errorf("time value has wrong Location: %s", x.
Location()) | 210 err = fmt.Errorf("time value has wrong Location: %s", x.
Location()) |
| 211 } | 211 } |
| 212 return PTTime, err | 212 return PTTime, err |
| 213 case GeoPoint: | 213 case GeoPoint: |
| 214 err := error(nil) | 214 err := error(nil) |
| 215 if checkValid && !x.Valid() { | 215 if checkValid && !x.Valid() { |
| 216 err = errors.New("invalid GeoPoint value") | 216 err = errors.New("invalid GeoPoint value") |
| 217 } | 217 } |
| 218 return PTGeoPoint, err | 218 return PTGeoPoint, err |
| 219 default: | 219 default: |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 dflt = UpconvertUnderlyingType(dflt) | 486 dflt = UpconvertUnderlyingType(dflt) |
| 487 cur, err := gm(key) | 487 cur, err := gm(key) |
| 488 if err != nil { | 488 if err != nil { |
| 489 return dflt | 489 return dflt |
| 490 } | 490 } |
| 491 if dflt != nil && reflect.TypeOf(cur) != reflect.TypeOf(dflt) { | 491 if dflt != nil && reflect.TypeOf(cur) != reflect.TypeOf(dflt) { |
| 492 return dflt | 492 return dflt |
| 493 } | 493 } |
| 494 return cur | 494 return cur |
| 495 } | 495 } |
| OLD | NEW |