Add partial import functionality (#812)

This commit is contained in:
WithoutPants
2020-09-20 18:36:02 +10:00
committed by GitHub
parent 7a45943e8e
commit 8866670e53
56 changed files with 5030 additions and 624 deletions

View File

@@ -2,11 +2,14 @@ package models
import (
"fmt"
"github.com/stashapp/stash/pkg/utils"
"strings"
"time"
"github.com/stashapp/stash/pkg/utils"
)
var currentLocation = time.Now().Location()
type JSONTime struct {
time.Time
}
@@ -28,3 +31,19 @@ func (jt *JSONTime) MarshalJSON() ([]byte, error) {
}
return []byte(fmt.Sprintf("\"%s\"", jt.Time.Format(time.RFC3339))), nil
}
func (jt JSONTime) GetTime() time.Time {
if currentLocation != nil {
if jt.IsZero() {
return time.Now().In(currentLocation)
} else {
return jt.Time.In(currentLocation)
}
} else {
if jt.IsZero() {
return time.Now()
} else {
return jt.Time
}
}
}