Skip to content

Commit

Permalink
Fix TimestampNano marshalling - float not a quoted float
Browse files Browse the repository at this point in the history
  • Loading branch information
c2h5oh committed Mar 17, 2017
1 parent 4b24642 commit 78bfff3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion enums.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mailgun

import (
"encoding/json"
"fmt"
"net"
"strconv"
Expand Down Expand Up @@ -61,7 +62,8 @@ type TimestampNano time.Time
// MarshalText satisfies TextMarshaler
func (tn TimestampNano) MarshalText() ([]byte, error) {
t := time.Time(tn)
return []byte(fmt.Sprintf("%d.%d", t.Unix(), t.Nanosecond())), nil
v := float64(t.Unix()) + float64(t.Nanosecond())/float64(time.Nanosecond)
return json.Marshal(v)
}

// UnmarshalText satisfies TextUnmarshaler
Expand Down

0 comments on commit 78bfff3

Please sign in to comment.