Compare commits

..

No commits in common. "7f499012a6ca4eefc0c3436e6879da796d988efd" and "25ed921736cae10de1f94b43205097b284befc9f" have entirely different histories.

2 changed files with 11 additions and 1 deletions

View file

@ -4,6 +4,7 @@ package common
import (
"fmt"
"strconv"
"strings"
"time"
)
@ -12,8 +13,17 @@ 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 json.Number `json:"access_token_expiration"`
AccessTokenExpiration common.KeepZero `json:"access_token_expiration"`
Token string `json:"token"`
JWTKey string `json:"jwt_key"`
LastUsedAt *common.PyTimestamp `json:"last_used_at"`