summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
authorDmitry Samuylov <dsamuylov@pharo.com>2018-08-29 18:44:00 -0400
committerElias Nahum <nahumhbl@gmail.com>2018-08-29 19:44:00 -0300
commiteffa9d33fcbbab27f69a4c59356a84f925d41baf (patch)
tree2d68627c0d364f3506cde3a4347907b9b7ed1755 /model
parente742ba7d517c38534fbd4bb964accfb8f18c7841 (diff)
downloadchat-effa9d33fcbbab27f69a4c59356a84f925d41baf.tar.gz
chat-effa9d33fcbbab27f69a4c59356a84f925d41baf.tar.bz2
chat-effa9d33fcbbab27f69a4c59356a84f925d41baf.zip
bug fix: after and before search flags should not be inclusive of the selected date (#9327)
* fix for date based flag support to make the after and before flags not inclusive of the selected date * updated search posts tests using date flags to take into account new non inclusive of the selected date behavior of those flags
Diffstat (limited to 'model')
-rw-r--r--model/search_params.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/model/search_params.go b/model/search_params.go
index 8ed1fccfb..b5600ee5a 100644
--- a/model/search_params.go
+++ b/model/search_params.go
@@ -6,6 +6,7 @@ package model
import (
"regexp"
"strings"
+ "time"
)
var searchTermPuncStart = regexp.MustCompile(`^[^\pL\d\s#"]+`)
@@ -27,13 +28,19 @@ type SearchParams struct {
// Returns the epoch timestamp of the start of the day specified by SearchParams.AfterDate
func (p *SearchParams) GetAfterDateMillis() int64 {
date := ParseDateFilterToTime(p.AfterDate)
- return GetStartOfDayMillis(date, p.TimeZoneOffset)
+ // travel forward 1 day
+ oneDay := time.Hour * 24
+ afterDate := date.Add(oneDay)
+ return GetStartOfDayMillis(afterDate, p.TimeZoneOffset)
}
// Returns the epoch timestamp of the end of the day specified by SearchParams.BeforeDate
func (p *SearchParams) GetBeforeDateMillis() int64 {
date := ParseDateFilterToTime(p.BeforeDate)
- return GetEndOfDayMillis(date, p.TimeZoneOffset)
+ // travel back 1 day
+ oneDay := time.Hour * -24
+ beforeDate := date.Add(oneDay)
+ return GetEndOfDayMillis(beforeDate, p.TimeZoneOffset)
}
// Returns the epoch timestamps of the start and end of the day specified by SearchParams.OnDate