24 lines
585 B
Go
24 lines
585 B
Go
package dashboard
|
|
|
|
import "strconv"
|
|
|
|
type PeriodeDashboardRequest struct {
|
|
Year int `form:"year" binding:"required,min=1"`
|
|
Month int `form:"month" binding:"required,min=1,max=12"`
|
|
}
|
|
|
|
func GenerateStartEndDate(req PeriodeDashboardRequest) (startDate string, endDate string) {
|
|
endYear := req.Year
|
|
endMonth := req.Month + 1
|
|
if req.Month >= 12 {
|
|
req.Month = 12
|
|
endYear = req.Year + 1
|
|
endMonth = 1
|
|
}
|
|
|
|
startDate = strconv.Itoa(req.Year) + "-" + strconv.Itoa(req.Month) + "-1"
|
|
endDate = strconv.Itoa(endYear) + "-" + strconv.Itoa(endMonth) + "-1"
|
|
|
|
return startDate, endDate
|
|
}
|