Skip to content

Commit

Permalink
treat number strings ending with . uniformely in the DurationConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
ulferts committed Jan 23, 2025
1 parent 0155c22 commit 005e391
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/services/duration_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ def output(duration_in_hours, format: default_format)

def parseable?(duration_string)
if number = Integer(duration_string, 10, exception: false) || Float(duration_string, exception: false)
number >= 0
# ruby 3.4 started being able to parse strings like "1." as 1.0.
# However, that does not work with ChronicDuration.
number >= 0 && !duration_string.ends_with?(".")
else
begin
do_parse(duration_string)
Expand Down

0 comments on commit 005e391

Please sign in to comment.