We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a9b26a9 commit 5437df6Copy full SHA for 5437df6
1 file changed
src/timer.cc
@@ -293,17 +293,11 @@ int Timer::dur() {
293
294
int Timer::CalcTimeDiff(int year, int month) {
295
296
- int timediff_ = 0;
297
- if (year >= 0) {
298
- timediff_ += (year - si_.y0) * cyclusYear;
299
- }
300
-
301
- if (month >= 0) {
302
- timediff_ += (month - si_.m0) * cyclusMonth;
303
+ int start_time = si_.y0 * cyclusYear + si_.m0 * cyclusMonth;
+ int time = year * cyclusYear + month * cyclusMonth;
304
305
// Casting because ctx_->dt() is uint64_t and so negatives don't play nice
306
- return timediff_ / static_cast<int>(ctx_->dt());
+ return (time - start_time) / static_cast<int>(ctx_->dt());
307
308
}
309
0 commit comments