Files
qbittorrent-sentinel/api/util_time.go
T
2026-07-11 23:10:14 -04:00

22 lines
389 B
Go

package api
import (
"encoding/json"
"time"
)
type UnixTimestamp struct {
time.Time
}
func (ut *UnixTimestamp) UnmarshalJSON(b []byte) error {
var timestamp int64
// Unmarshal the raw JSON bytes into an int64
if err := json.Unmarshal(b, &timestamp); err != nil {
return err
}
// Convert the epoch seconds to a time.Time object
ut.Time = time.Unix(timestamp, 0)
return nil
}