mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 04:14:39 +03:00
Support today, yesterday when using parseDate in scrapers (#1261)
This commit is contained in:
@@ -362,6 +362,17 @@ type postProcessParseDate string
|
||||
func (p *postProcessParseDate) Apply(value string, q mappedQuery) string {
|
||||
parseDate := string(*p)
|
||||
|
||||
const internalDateFormat = "2006-01-02"
|
||||
|
||||
value = strings.ToLower(value)
|
||||
if value == "today" || value == "yesterday" { // handle today, yesterday
|
||||
dt := time.Now()
|
||||
if value == "yesterday" { // subtract 1 day from now
|
||||
dt = dt.AddDate(0, 0, -1)
|
||||
}
|
||||
return dt.Format(internalDateFormat)
|
||||
}
|
||||
|
||||
if parseDate == "" {
|
||||
return value
|
||||
}
|
||||
@@ -375,7 +386,6 @@ func (p *postProcessParseDate) Apply(value string, q mappedQuery) string {
|
||||
}
|
||||
|
||||
// convert it into our date format
|
||||
const internalDateFormat = "2006-01-02"
|
||||
return parsedValue.Format(internalDateFormat)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user