MCPcopy Index your code
hub / github.com/TruthHun/BookStack / getTimeRange

Function getTimeRange

models/base.go:232–255  ·  view source on GitHub ↗
(t time.Time, prd period)

Source from the content-addressed store, hash-verified

230}
231
232func getTimeRange(t time.Time, prd period) (start, end string) {
233 switch prd {
234 case PeriodWeek:
235 start, end = getWeek(t)
236 case PeriodLastWeek:
237 start, end = getWeek(t.AddDate(0, 0, -7))
238 case PeriodMonth:
239 start, end = getMonth(t)
240 case PeriodLastMoth:
241 start, end = getMonth(t.AddDate(0, -1, 0))
242 case PeriodAll:
243 start = "20060102"
244 end = "20401231"
245 case PeriodDay:
246 start = t.Format(dateFormat)
247 end = start
248 case PeriodYear:
249 start, end = getYear(t.AddDate(-1, 0, 0))
250 default:
251 start = t.Format(dateFormat)
252 end = start
253 }
254 return
255}
256
257func getWeek(t time.Time) (start, end string) {
258 if t.Weekday() == 0 {

Callers 4

SortedByPeriodMethod · 0.85
GetReadingTimeMethod · 0.85
SortMethod · 0.85
_sortMethod · 0.85

Calls 3

getWeekFunction · 0.85
getMonthFunction · 0.85
getYearFunction · 0.85

Tested by

no test coverage detected