mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Date precision (#6359)
* Remove month/year only formats from ParseDateStringAsTime * Add precision field to Date and handle parsing year/month-only dates * Add date precision columns for date columns * Adjust UI to account for fuzzy dates
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
"gopkg.in/guregu/null.v4"
|
||||
)
|
||||
|
||||
const sqliteDateLayout = "2006-01-02"
|
||||
@@ -54,12 +55,12 @@ func (d NullDate) Value() (driver.Value, error) {
|
||||
return d.Date.Format(sqliteDateLayout), nil
|
||||
}
|
||||
|
||||
func (d *NullDate) DatePtr() *models.Date {
|
||||
func (d *NullDate) DatePtr(precision null.Int) *models.Date {
|
||||
if d == nil || !d.Valid {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &models.Date{Time: d.Date}
|
||||
return &models.Date{Time: d.Date, Precision: models.DatePrecision(precision.Int64)}
|
||||
}
|
||||
|
||||
func NullDateFromDatePtr(d *models.Date) NullDate {
|
||||
@@ -68,3 +69,11 @@ func NullDateFromDatePtr(d *models.Date) NullDate {
|
||||
}
|
||||
return NullDate{Date: d.Time, Valid: true}
|
||||
}
|
||||
|
||||
func datePrecisionFromDatePtr(d *models.Date) null.Int {
|
||||
if d == nil {
|
||||
// default to day precision
|
||||
return null.Int{}
|
||||
}
|
||||
return null.IntFrom(int64(d.Precision))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user