-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add date bound filter func
- Loading branch information
1 parent
c8876ae
commit 732f5e1
Showing
2 changed files
with
28 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
package main | ||
|
||
import "go.mongodb.org/mongo-driver/bson" | ||
import "time" | ||
|
||
func Sel(query map[string]string) bson.M { | ||
result := make(bson.M, len(query)) | ||
for k, v := range query { | ||
result[k] = v | ||
func GetValidDateLowerAndUpperBound() (time.Time, time.Time) { | ||
now := time.Now() | ||
var lowerBound time.Time | ||
var upperBound time.Time | ||
if now.Hour() <= 12 { | ||
lowerBound = time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.Local) | ||
upperBound = time.Date(now.Year(), now.Month(), now.Day(), 12, 0, 0, 0, time.Local) | ||
} else { | ||
lowerBound = time.Date(now.Year(), now.Month(), now.Day(), 12, 0, 0, 0, time.Local) | ||
upperBound = time.Date(now.Year(), now.Month(), now.Day(), 24, 0, 0, 0, time.Local) | ||
} | ||
return result | ||
return lowerBound, upperBound | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters