mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
* Add new txn manager interface * Add txn management to sqlite * Rename get to getByID * Add contexts to repository methods * Update query builders * Add context to reader writer interfaces * Use repository in resolver * Tighten interfaces * Tighten interfaces in dlna * Tighten interfaces in match package * Tighten interfaces in scraper package * Tighten interfaces in scan code * Tighten interfaces on autotag package * Remove ReaderWriter usage * Merge database package into sqlite
32 lines
509 B
Go
32 lines
509 B
Go
package sqlite
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func durationToTinyIntFn(str string) (int64, error) {
|
|
splits := strings.Split(str, ":")
|
|
|
|
if len(splits) > 3 {
|
|
return 0, nil
|
|
}
|
|
|
|
seconds := 0
|
|
factor := 1
|
|
for len(splits) > 0 {
|
|
// pop the last split
|
|
var thisSplit string
|
|
thisSplit, splits = splits[len(splits)-1], splits[:len(splits)-1]
|
|
|
|
thisInt, err := strconv.Atoi(thisSplit)
|
|
if err != nil {
|
|
return 0, nil
|
|
}
|
|
|
|
seconds += factor * thisInt
|
|
factor *= 60
|
|
}
|
|
|
|
return int64(seconds), nil
|
|
}
|