mirror of
https://github.com/GrassrootsEconomics/cic-dw.git
synced 2024-12-22 19:07:33 +01:00
27 lines
543 B
Go
27 lines
543 B
Go
|
package dashboard
|
||
|
|
||
|
import (
|
||
|
"github.com/golang-module/carbon/v2"
|
||
|
"net/url"
|
||
|
)
|
||
|
|
||
|
func parseDateRange(q url.Values) (string, string) {
|
||
|
var from, to string
|
||
|
|
||
|
qFrom := q.Get("from")
|
||
|
qTo := q.Get("to")
|
||
|
|
||
|
parseFrom := carbon.Parse(qFrom)
|
||
|
parseTo := carbon.Parse(qTo)
|
||
|
|
||
|
if parseFrom.Error != nil || parseTo.Error != nil || qFrom == "" || qTo == "" {
|
||
|
from = carbon.Now().StartOfMonth().ToDateString()
|
||
|
to = carbon.Now().EndOfMonth().ToDateString()
|
||
|
} else {
|
||
|
from = parseFrom.ToDateString()
|
||
|
to = parseTo.ToDateString()
|
||
|
}
|
||
|
|
||
|
return from, to
|
||
|
}
|