change around pings, fix main.js so the actual real fucking number shows instead of it freaking out.
This commit is contained in:
@@ -3,36 +3,44 @@ package handlers
|
||||
import "encoding/json"
|
||||
|
||||
func extractTimestamp(v interface{}) int64 {
|
||||
ts, ok := extractTimestampIfPresent(v)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return ts
|
||||
}
|
||||
|
||||
func extractTimestampIfPresent(v interface{}) (int64, bool) {
|
||||
switch t := v.(type) {
|
||||
case uint64:
|
||||
if t <= uint64(^uint64(0)>>1) {
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
}
|
||||
return 0
|
||||
return 0, false
|
||||
case uint32:
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
case uint16:
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
case uint8:
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
case int64:
|
||||
return t
|
||||
return t, true
|
||||
case int32:
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
case int16:
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
case int8:
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
case int:
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
case float64:
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
case float32:
|
||||
return int64(t)
|
||||
return int64(t), true
|
||||
case json.Number:
|
||||
if n, err := t.Int64(); err == nil {
|
||||
return n
|
||||
return n, true
|
||||
}
|
||||
}
|
||||
return 0
|
||||
return 0, false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user