Index: service/datastore/serialize/serialize.go |
diff --git a/service/datastore/serialize/serialize.go b/service/datastore/serialize/serialize.go |
index 736010820f222499212728ca30154029a905cc4f..a6210c6b49f6ed381b397f6fbdc6408316b35bf2 100644 |
--- a/service/datastore/serialize/serialize.go |
+++ b/service/datastore/serialize/serialize.go |
@@ -189,6 +189,13 @@ func ReadGeoPoint(buf Buffer) (gp ds.GeoPoint, err error) { |
return |
} |
+// timeToInt converts a time value to an integer value. See WriteTime for more |
+// details. |
+func timeToInt(t time.Time) int64 { |
+ t = t.Round(time.Microsecond) |
+ return t.Unix()*1e6 + int64(t.Nanosecond()/1e3) |
+} |
+ |
// WriteTime writes a time.Time in a byte-sortable way. |
// |
// This method truncates the time to microseconds and drops the timezone, |
@@ -198,7 +205,7 @@ func WriteTime(buf Buffer, t time.Time) error { |
if name != "UTC" || off != 0 { |
panic(fmt.Errorf("helper: UTC OR DEATH: %s", t)) |
} |
- _, err := cmpbin.WriteInt(buf, t.Unix()*1e6+int64(t.Nanosecond()/1e3)) |
+ _, err := cmpbin.WriteInt(buf, timeToInt(t)) |
return err |
} |
@@ -220,7 +227,14 @@ func ReadTime(buf Buffer) (time.Time, error) { |
// Key as its Value. |
func WriteProperty(buf Buffer, context KeyContext, p ds.Property) (err error) { |
defer recoverTo(&err) |
- typb := byte(p.Type()) |
+ |
+ effectiveType := p.Type() |
+ switch effectiveType { |
+ case ds.PTTime: |
dnj
2015/12/29 16:48:09
I made this a switch statement in case there were
|
+ effectiveType = ds.PTInt |
+ } |
+ typb := byte(effectiveType) |
iannucci
2015/12/29 18:29:20
This change is not good; it will call property map
|
+ |
if p.IndexSetting() != ds.NoIndex { |
typb |= 0x80 |
} |