summaryrefslogtreecommitdiff
path: root/internal/media/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/media/util.go')
-rw-r--r--internal/media/util.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/media/util.go b/internal/media/util.go
index 6dfcede89..9d62619f5 100644
--- a/internal/media/util.go
+++ b/internal/media/util.go
@@ -21,6 +21,7 @@ package media
import (
"errors"
"fmt"
+ "time"
"github.com/h2non/filetype"
"github.com/sirupsen/logrus"
@@ -128,3 +129,19 @@ func (l *logrusWrapper) Info(msg string, keysAndValues ...interface{}) {
func (l *logrusWrapper) Error(err error, msg string, keysAndValues ...interface{}) {
logrus.Error("media manager cron logger: ", err, msg, keysAndValues)
}
+
+func parseOlderThan(olderThanDays int) (time.Time, error) {
+ // convert days into a duration string
+ olderThanHoursString := fmt.Sprintf("%dh", olderThanDays*24)
+
+ // parse the duration string into a duration
+ olderThanHours, err := time.ParseDuration(olderThanHoursString)
+ if err != nil {
+ return time.Time{}, err
+ }
+
+ // 'subtract' that from the time now to give our threshold
+ olderThan := time.Now().Add(-olderThanHours)
+
+ return olderThan, nil
+}