From 7501cf77819f5648192729e2230a93c344048cfb Mon Sep 17 00:00:00 2001 From: Christian Klein Date: Wed, 4 May 2022 16:19:57 +0200 Subject: [PATCH] Fix to allow negative Values --- src/PC/Helpers.elm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/PC/Helpers.elm b/src/PC/Helpers.elm index 41d09eb..63b1b8b 100644 --- a/src/PC/Helpers.elm +++ b/src/PC/Helpers.elm @@ -9,12 +9,21 @@ import Http exposing (..) -- Please note that only 0 are added. The number will not be shortend! addLeadingZero : Int -> Int -> String addLeadingZero number length = - let - num_str = String.fromInt number - in - (String.fromList <| List.repeat (length - String.length num_str) '0' - ) - ++ num_str + if number >= 0 then + let + num_str = String.fromInt number + in + (String.fromList <| List.repeat (length - String.length num_str) '0' + ) + ++ num_str + else + let + num_str = String.fromInt <| 0-number + in + "-" ++ + (String.fromList <| List.repeat (length - String.length num_str) '0' + ) + ++ num_str -- Get the value at a given position in a List.