Skip to content

Commit

Permalink
Minor cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
wichtounet committed Oct 9, 2023
1 parent ebd85f6 commit 7918c89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
7 changes: 2 additions & 5 deletions src/overview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,7 @@ budget::month get_current_months(data_cache & cache, budget::year year){
auto sm = start_month(cache, year);
budget::month current_months = budget::month(12) - sm + budget::month(1);

auto today = budget::local_day();

if(today.year() == year){
if(auto today = budget::local_day(); today.year() == year){
current_months = today.month() - sm + date_type(1);
}

Expand Down Expand Up @@ -1008,8 +1006,7 @@ void budget::display_balance(budget::writer& w, budget::year year, bool relaxed,
auto today = budget::local_day();
if(year > today.year()){
auto pretotal = compute_total_budget(w.cache, sm, year);
size_t i = 0;
for(const auto& account : all_accounts(w.cache, year, sm)){
for(size_t i = 0; const auto& account : all_accounts(w.cache, year, sm)){
account_previous[account.name][sm.value - 1] += pretotal[i++] - account.amount;
}
}
Expand Down
11 changes: 4 additions & 7 deletions src/share.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,17 @@ budget::date get_valid_date(const budget::date & d){
if (d >= budget::local_day()) {
auto now = std::chrono::system_clock::now();
auto tt = std::chrono::system_clock::to_time_t(now);
auto tm = *std::localtime(&tt);

// We make sure that we are on a new U.S: day
// TODO This should be done by getting the current time in the U.S.
if (tm.tm_hour > 15) {
if (auto tm = *std::localtime(&tt); tm.tm_hour > 15) {
return get_valid_date(budget::local_day() - budget::days(1));
}

return get_valid_date(budget::local_day() - budget::days(2));
}

auto dow = d.day_of_the_week();

if (dow == 6 || dow == 7){
if (auto dow = d.day_of_the_week(); dow == 6 || dow == 7){
return get_valid_date(d - budget::days(dow - 5));
}

Expand Down Expand Up @@ -149,9 +146,9 @@ std::map<share_price_cache_key, budget::money, std::less<>> get_share_price_v3(c
const share_price_cache_key key(d, ticker);
quotes[key] = m;
}
} catch (const budget::date_exception& e) {
} catch (const budget::date_exception&) {
return {};
} catch (const budget::budget_exception& e) {
} catch (const budget::budget_exception&) {
return {};
}

Expand Down

0 comments on commit 7918c89

Please sign in to comment.