mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-09-01 07:26:23 -07:00
Refactor FuzzyTime.Match to simplify time comparison logic
This commit is contained in:
parent
6cf305d38c
commit
0b0987efad
1 changed files with 2 additions and 3 deletions
|
@ -58,17 +58,16 @@ func (f FuzzyTime) Match(val driver.Value) bool {
|
|||
var t time.Time
|
||||
switch timeVal := val.(type) {
|
||||
case time.Time:
|
||||
t = timeVal.Truncate(time.Minute)
|
||||
t = timeVal
|
||||
case string:
|
||||
var err error
|
||||
t, err = time.Parse(time.RFC3339, timeVal)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
t = t.Truncate(time.Minute)
|
||||
default:
|
||||
return false
|
||||
}
|
||||
|
||||
return t.After(ft.Add(-10*time.Minute)) && t.Before(ft.Add(10*time.Minute))
|
||||
return t.Truncate(10 * time.Minute).Equal(ft.Truncate(10 * time.Minute))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue