mirror of
https://github.com/kataras/iris.git
synced 2026-01-09 21:15:56 +00:00
add x/timex.GetMonthDays, GetMonthEnd and x/jsonx.SimpleDates type and x/jsonx.GetSimpleDateRange function
This commit is contained in:
@@ -116,6 +116,18 @@ func GetMonthStart(now time.Time) time.Time {
|
||||
return time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, now.Location())
|
||||
}
|
||||
|
||||
// GetMonthEnd returns the date of the last month day of the current now's month.
|
||||
func GetMonthEnd(now time.Time) time.Time {
|
||||
now = now.UTC()
|
||||
// Add one month to the current date and subtract one day
|
||||
return time.Date(now.Year(), now.Month()+1, 0, 0, 0, 0, 0, now.Location())
|
||||
}
|
||||
|
||||
// GetMonthDays returns the range between first and last days the current month.
|
||||
func GetMonthDays(now time.Time) (dates []time.Time) {
|
||||
return Between(GetMonthStart(now), GetMonthEnd(now))
|
||||
}
|
||||
|
||||
// GetYearStart returns the date of the first year of the current now's year.
|
||||
func GetYearStart(now time.Time) time.Time {
|
||||
return time.Date(now.Year(), 1, 1, 0, 0, 0, 0, now.Location())
|
||||
|
||||
Reference in New Issue
Block a user