mirror of
https://github.com/stashapp/stash.git
synced 2025-12-07 08:54:10 +01:00
* Remove ID from PerformerPartial * Separate studio model from sqlite model * Separate movie model from sqlite model * Separate tag model from sqlite model * Separate saved filter model from sqlite model * Separate scene marker model from sqlite model * Separate gallery chapter model from sqlite model * Move ErrNoRows checks into sqlite, improve empty result error messages * Move SQLiteDate and SQLiteTimestamp to sqlite * Use changesetTranslator everywhere, refactor for consistency * Make PerformerStore.DestroyImage private * Fix rating on movie create
34 lines
635 B
Go
34 lines
635 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
const railsTimeLayout = "2006-01-02 15:04:05 MST"
|
|
|
|
func ParseDateStringAsTime(dateString string) (time.Time, error) {
|
|
// https://stackoverflow.com/a/20234207 WTF?
|
|
|
|
t, e := time.Parse(time.RFC3339, dateString)
|
|
if e == nil {
|
|
return t, nil
|
|
}
|
|
|
|
t, e = time.Parse("2006-01-02", dateString)
|
|
if e == nil {
|
|
return t, nil
|
|
}
|
|
|
|
t, e = time.Parse("2006-01-02 15:04:05", dateString)
|
|
if e == nil {
|
|
return t, nil
|
|
}
|
|
|
|
t, e = time.Parse(railsTimeLayout, dateString)
|
|
if e == nil {
|
|
return t, nil
|
|
}
|
|
|
|
return time.Time{}, fmt.Errorf("ParseDateStringAsTime failed: dateString <%s>", dateString)
|
|
}
|