From ed5886921bcce0d1a261a37aa83bf135259b7d21 Mon Sep 17 00:00:00 2001 From: Rafael Ascensão Date: Sat, 25 Sep 2021 23:47:08 +0100 Subject: Fix --time-colon for negative time amounts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While the current formula works for positive numbers, negative numbers are incorrectly represented. One of the issues comes from the fact that floor(x) < x for every x. `amount_t precision` will always be a non negative number and the code that attempts to fix the issue for negative number will never run. If we truncate the number instead, the current formula works for both positive and negative numbers without making negative numbers a corner case. So let's do that. Signed-off-by: Rafael Ascensão --- test/regress/1176.test | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/regress/1176.test (limited to 'test/regress') diff --git a/test/regress/1176.test b/test/regress/1176.test new file mode 100644 index 00000000..6c23c8bd --- /dev/null +++ b/test/regress/1176.test @@ -0,0 +1,23 @@ +2016-01-01 Employer + Me -5400s + Them 5400s +2016-01-01 Employer + Me -3600s + Them 3600s +2016-01-02 Employer + Me -1800s + Them 1800s +2016-01-02 Employer + Me -30s + Them 30s + +test reg --time-colon +16-Jan-01 Employer Me -1:30h -1:30h + Them 1:30h 0 +16-Jan-01 Employer Me -1:00h -1:00h + Them 1:00h 0 +16-Jan-02 Employer Me -30:0m -30:0m + Them 30:0m 0 +16-Jan-02 Employer Me -30s -30s + Them 30s 0 +end test -- cgit v1.2.3