stash/pkg/models/date.go
DingDongSoLong4 5580525c2d
SQLite model refactoring, part 2 (#3839)
* Treat empty image input as null
* Add validation to models.Date
* Allow zero dates in database
* Make scene_markers.scene_id non-nullable
* Drop scraped_items table
* Remove movie/studio checksum
* Add migration notes
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2023-07-13 12:15:02 +10:00

27 lines
496 B
Go

package models
import (
"time"
"github.com/stashapp/stash/pkg/utils"
)
// Date wraps a time.Time with a format of "YYYY-MM-DD"
type Date struct {
time.Time
}
const dateFormat = "2006-01-02"
func (d Date) String() string {
return d.Format(dateFormat)
}
// ParseDate uses utils.ParseDateStringAsTime to parse a string into a date.
func ParseDate(s string) (Date, error) {
ret, err := utils.ParseDateStringAsTime(s)
if err != nil {
return Date{}, err
}
return Date{Time: ret}, nil
}