MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / computeDateRange

Function computeDateRange

src/utils/timeTrackingUtils.ts:136–169  ·  view source on GitHub ↗
(options: TimeSummaryOptions)

Source from the content-addressed store, hash-verified

134}
135
136function computeDateRange(options: TimeSummaryOptions): { startDate: Date; endDate: Date } {
137 let startDate: Date;
138 let endDate: Date = new Date();
139
140 switch (options.period) {
141 case "today":
142 startDate = new Date();
143 startDate.setHours(0, 0, 0, 0);
144 break;
145 case "week":
146 startDate = new Date();
147 startDate.setDate(startDate.getDate() - startDate.getDay());
148 startDate.setHours(0, 0, 0, 0);
149 break;
150 case "month":
151 startDate = new Date();
152 startDate.setDate(1);
153 startDate.setHours(0, 0, 0, 0);
154 break;
155 case "all":
156 startDate = new Date(0);
157 break;
158 default:
159 if (options.fromDate) {
160 startDate = options.fromDate;
161 if (options.toDate) endDate = options.toDate;
162 } else {
163 startDate = new Date();
164 startDate.setHours(0, 0, 0, 0);
165 }
166 }
167
168 return { startDate, endDate };
169}
170
171export function computeTimeSummary(
172 tasks: TaskInfo[],

Callers 1

computeTimeSummaryFunction · 0.85

Calls 1

getDateMethod · 0.65

Tested by

no test coverage detected