Skip to content

#511: Correct sign in Fbe.sec so elapsed seconds format as past#518

Open
VasilevNStas wants to merge 2 commits into
zerocracy:masterfrom
VasilevNStas:fix/511-sec-ago
Open

#511: Correct sign in Fbe.sec so elapsed seconds format as past#518
VasilevNStas wants to merge 2 commits into
zerocracy:masterfrom
VasilevNStas:fix/511-sec-ago

Conversation

@VasilevNStas

Copy link
Copy Markdown
Contributor

Description

Fbe.sec used (Time.now + s).ago, which for a positive s formatted a future time as "from now". The method's purpose is to format elapsed seconds (past time), so the sign was wrong.

Fix

Changed line 29 from (Time.now + s).ago to (Time.now - s).ago. Updated YARD docstring to match the actual tago gem output format (short form: "2h" instead of "2 hours ago").

Closes #511

Tests

  • test_elapsed_past — verifies that Fbe.sec returns "2h" for a fact with seconds = 7200 (would return "1h59m" with the buggy code)

Verification

  • bundle exec rubocop — 0 offenses
  • bundle exec rake test — 0 failures

@kreinba kreinba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sign flip from (Time.now + s).ago to (Time.now - s).ago matches the elapsed-time contract that the method name and YARD example promise, and resolves #511. New test test_elapsed_past pins the 7200-second case to '2h' using Time.stub from minitest/mock (already required in test/test__helper.rb), which is a strict guard the prior start_with?('5m') assertion was missing. Docstring is realigned to the short tago form. CI is green on every check.

@0crat

0crat commented Jun 4, 2026

Copy link
Copy Markdown

@kreinba Great work on the review! 🎉 You've earned +6 points (base +18, -8 for missing comments, -4 for low code coverage with 18 hits). Your total score is now +1538 - keep up the momentum and check your Zerocracy account for updates!

@VasilevNStas VasilevNStas changed the title fix: correct sign in Fbe.sec so elapsed seconds format as past #511 fix: correct sign in Fbe.sec so elapsed seconds format as past Jun 8, 2026
@VasilevNStas VasilevNStas changed the title #511 fix: correct sign in Fbe.sec so elapsed seconds format as past #511: Correct sign in Fbe.sec so elapsed seconds format as past Jun 8, 2026
@yegor256

Copy link
Copy Markdown
Member

@VasilevNStas merge conflict here

@yegor256

Copy link
Copy Markdown
Member

Please fix the merge conflicts so this pull request can be merged.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 plz re-review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fbe.sec uses Time.now + s and returns "from now" while docstring example promises "ago"

4 participants