Compare commits

...

2 commits

Author SHA1 Message Date
7f499012a6 just use json.Number 2022-11-13 12:15:25 -05:00
1ea8a24224 gofmt 2022-11-13 12:04:44 -05:00
2 changed files with 1 additions and 11 deletions

View file

@ -4,7 +4,6 @@ package common
import (
"fmt"
"strconv"
"strings"
"time"
)
@ -13,17 +12,8 @@ type (
// PyTimeStamp is a python-style long nano timestamp
PyTimestamp time.Time
// KeepZero is a special float that keeps the trailing zero on marshal
KeepZero float64
)
func (f KeepZero) MarshalJSON() ([]byte, error) {
if float64(f) == float64(int(f)) {
return []byte(strconv.FormatFloat(float64(f), 'f', 1, 32)), nil
}
return []byte(strconv.FormatFloat(float64(f), 'f', -1, 32)), nil
}
const PytTimeFormat = "2006-01-02T15:04:05.999999-07:00"
func (t *PyTimestamp) MarshalJSON() ([]byte, error) {

View file

@ -25,7 +25,7 @@ type RefreshToken struct {
ClientIcon *string `json:"client_icon"`
TokenType TokenType `json:"token_type"`
CreatedAt *common.PyTimestamp `json:"created_at"`
AccessTokenExpiration common.KeepZero `json:"access_token_expiration"`
AccessTokenExpiration json.Number `json:"access_token_expiration"`
Token string `json:"token"`
JWTKey string `json:"jwt_key"`
LastUsedAt *common.PyTimestamp `json:"last_used_at"`