We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c0ffb89 commit a2aa655Copy full SHA for a2aa655
types.go
@@ -3,6 +3,7 @@ package jwt
3
import (
4
"encoding/json"
5
"fmt"
6
+ "math"
7
"reflect"
8
"strconv"
9
"time"
@@ -41,7 +42,8 @@ func NewNumericDate(t time.Time) *NumericDate {
41
42
// newNumericDateFromSeconds creates a new *NumericDate out of a float64 representing a
43
// UNIX epoch with the float fraction representing non-integer seconds.
44
func newNumericDateFromSeconds(f float64) *NumericDate {
- return NewNumericDate(time.Unix(0, int64(f*float64(time.Second))))
45
+ round, frac := math.Modf(f)
46
+ return NewNumericDate(time.Unix(int64(round), int64(frac*1e9)))
47
}
48
49
// MarshalJSON is an implementation of the json.RawMessage interface and serializes the UNIX epoch
0 commit comments