parent
b110cdcacc
commit
b37dd824de
@ -0,0 +1,41 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
JSTime time.Time
|
||||
)
|
||||
|
||||
const (
|
||||
jsTimeLite = "2006-01-02"
|
||||
jsTimeLayout = "2006-01-02 15:04:05"
|
||||
)
|
||||
|
||||
func (ct *JSTime) UnmarshalJSON(b []byte) (err error) {
|
||||
s := strings.Trim(string(b), `"`)
|
||||
loc, _ := time.LoadLocation("Europe/Madrid")
|
||||
nt, err := time.ParseInLocation(jsTimeLayout, s, loc)
|
||||
*ct = JSTime(nt)
|
||||
return
|
||||
}
|
||||
|
||||
func (ct JSTime) MarshalJSON() ([]byte, error) {
|
||||
return []byte(ct.String()), nil
|
||||
}
|
||||
|
||||
func (ct JSTime) String() string {
|
||||
t := time.Time(ct)
|
||||
return fmt.Sprintf("%q", t.Format(jsTimeLayout))
|
||||
}
|
||||
|
||||
func (ct JSTime) Unix() int64 {
|
||||
return time.Time(ct).Unix()
|
||||
}
|
||||
|
||||
func (ct JSTime) Local() JSTime {
|
||||
return JSTime(time.Time(ct).Local())
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package storage
|
||||
|
||||
type (
|
||||
Media struct {
|
||||
Type string `json:"type"`
|
||||
File string `json:"file"`
|
||||
Height int `json:"height"`
|
||||
Width int `json:"width"`
|
||||
}
|
||||
)
|
Loading…
Reference in new issue