Private
Public Access
1
0
Files
Kordophone/model/date.go
2024-01-05 16:26:19 -08:00

31 lines
596 B
Go

package model
import (
"fmt"
"time"
)
type Date time.Time
func (d Date) Equal(other Date) bool {
return time.Time(d).Equal(time.Time(other))
}
func (d Date) After(other Date) bool {
return time.Time(d).After(time.Time(other))
}
func (d Date) Before(other Date) bool {
return time.Time(d).Before(time.Time(other))
}
func (d Date) Format(layout string) string {
return time.Time(d).Format(layout)
}
func (t Date) MarshalJSON() ([]byte, error) {
// Must use ISO8601
formatted := fmt.Sprintf("\"%s\"", time.Time(t).Format("2006-01-02T15:04:05+00:00"))
return []byte(formatted), nil
}