Fix removing target charge time (#2066)
This commit is contained in:
parent
5ca18306c4
commit
57f5a72055
14 changed files with 69 additions and 43 deletions
|
|
@ -90,6 +90,12 @@ func NewSocketHub() *SocketHub {
|
|||
func encode(v interface{}) (string, error) {
|
||||
var s string
|
||||
switch val := v.(type) {
|
||||
case time.Time:
|
||||
var b []byte
|
||||
if !val.IsZero() {
|
||||
b, _ = val.MarshalText()
|
||||
}
|
||||
s = fmt.Sprintf(`"%s"`, string(b))
|
||||
case time.Duration:
|
||||
// must be before stringer to convert to seconds instead of string
|
||||
s = fmt.Sprintf("%d", int64(val.Seconds()))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue