mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: make range picker show actual range with ceiled to date (fix #175)
This commit is contained in:
@ -10,7 +10,7 @@ func StartOfToday() time.Time {
|
||||
}
|
||||
|
||||
func StartOfDay(date time.Time) time.Time {
|
||||
return time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, date.Location())
|
||||
return FloorDate(date)
|
||||
}
|
||||
|
||||
func StartOfWeek() time.Time {
|
||||
@ -29,6 +29,20 @@ func StartOfYear() time.Time {
|
||||
return time.Date(ref.Year(), time.January, 1, 0, 0, 0, 0, ref.Location())
|
||||
}
|
||||
|
||||
// FloorDate rounds date down to the start of the day
|
||||
func FloorDate(date time.Time) time.Time {
|
||||
return date.Truncate(24 * time.Hour)
|
||||
}
|
||||
|
||||
// CeilDate rounds date up to the start of next day if date is not already a start (00:00:00)
|
||||
func CeilDate(date time.Time) time.Time {
|
||||
floored := FloorDate(date)
|
||||
if floored == date {
|
||||
return floored
|
||||
}
|
||||
return floored.Add(24 * time.Hour)
|
||||
}
|
||||
|
||||
func SplitRangeByDays(from time.Time, to time.Time) [][]time.Time {
|
||||
intervals := make([][]time.Time, 0)
|
||||
|
||||
|
Reference in New Issue
Block a user