(options: TimeSummaryOptions)
| 134 | } |
| 135 | |
| 136 | function 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 | |
| 171 | export function computeTimeSummary( |
| 172 | tasks: TaskInfo[], |
no test coverage detected