Skip to content

Conversation

@jonatack
Copy link
Member

Updates formatDurationStr() to use the chrono standard lib. No change in behavior.

@jonatack jonatack changed the title gui, refactor: use std::chrono for formatDurationStr() helper refactor: use std::chrono for formatDurationStr() helper Feb 15, 2022
Copy link
Contributor

@shaavan shaavan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6f2593d

The updated code looks clean and is straightforward to understand. I was able to compile the PR branch successfully and test that updated formatDurationStr is providing correct results for the ui->peerConnTime.

Here is a screenshot of the correct working of the PR.

PR

As a small nit suggestion, I think it would be a good idea to space out the code a little bit into logical sections. But this is a non-critical suggestion, and you may take it up in case you are going to update the PR for some other reasons.

Copy link
Contributor

@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK 6f2593d on Ubuntu 21.10 Qt 5.15.2

const auto m{std::chrono::duration_cast<std::chrono::minutes>(dur - d - h)};
const auto s{std::chrono::duration_cast<std::chrono::seconds>(dur - d - h - m)};
QStringList str_list;
if (auto d2{d.count()}) str_list.append(QObject::tr("%1 d").arg(d2));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add translator comments, here and after?

Copy link
Member Author

@jonatack jonatack Feb 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, doing for several of these (FormatPeerAge, formatDurationStr, TimeDurationField, etc.) as a follow-up to this and to #543 (see #543 (comment)). That way this remains a straight refactor and current review on both pulls isn't invalidated.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 6f2593d.

Maybe leave a comment that <format> can be used once we jump to C++20.

if (auto h2{h.count()}) str_list.append(QObject::tr("%1 h").arg(h2));
if (auto m2{m.count()}) str_list.append(QObject::tr("%1 m").arg(m2));
const auto s2{s.count()};
if (s2 || str_list.empty()) str_list.append(QObject::tr("%1 s").arg(s2));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6f2593d

nit, suggestion:

if (auto s2{s.count()}) str_list.append(QObject::tr("%1 s").arg(s2));
return str_list.empty() ? "0 s" : str_list.join(" ");

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do if have to retouch or will sneak it into the translator comments follow-up.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: When following up - "Connection Age" will bring the naming convention together - in the gui as well as CL

tr("Age")

@RandyMcMillan
Copy link
Contributor

tACK 6f2593d

tested on macOS x86_64, Arm64

Screen Shot 2022-03-01 at 3 17 51 PM

Screen Shot 2022-03-01 at 3 19 26 PM

@hebasto hebasto merged commit c8f2817 into bitcoin-core:master Mar 5, 2022
@jonatack jonatack deleted the formatDurationStr-std-chrono branch March 5, 2022 17:09
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Mar 6, 2022
…ionStr() helper

6f2593d gui, refactor: use std::chrono for formatDurationStr() helper (Jon Atack)

Pull request description:

  Updates `formatDurationStr()` to use the `chrono` standard lib. No change in behavior.

ACKs for top commit:
  RandyMcMillan:
    tACK 6f2593d
  shaavan:
    ACK 6f2593d
  w0xlt:
    tACK 6f2593d on Ubuntu 21.10 Qt 5.15.2
  promag:
    Code review ACK 6f2593d.

Tree-SHA512: 61e9afdb1db779150df338e6af08727c34f69639add465c2f7003ff775d97dce3e78e78d325bc6dea5bc13f0fce9ef1c3506d13f1661a5e083e52bba8a32ba44
@bitcoin-core bitcoin-core locked and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants