Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
docelic committed Jan 6, 2024
1 parent bbd81dd commit d5b7bcb
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/virtualtime.cr
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ class VirtualTime
_nanosecond, _second, _minute, _hour, carry = materialize_time_with_hint time, carry
_day, _month, _year, carry = materialize_date_with_hint time, carry

if carry > 0
raise ArgumentError.new "Cannot find compliant materialized time"
end
# if carry > 0
# raise ArgumentError.new "Cannot find compliant materialized time"
# end

{year: _year, month: _month, day: _day, hour: _hour, minute: _minute, second: _second, nanosecond: _nanosecond}
end
Expand Down Expand Up @@ -380,9 +380,10 @@ class VirtualTime
# some max attempts of trying to find a value that simultaneously satisfies all constraints.
def to_time(hint = Time.local.at_beginning_of_minute, strict = true)
begin
time = Time.local **materialize_with_hint(hint), location: hint.location
rescue ArgumentError
raise ArgumentError.new "#{inspect} with hint #{hint} produced an invalid Time"
timespec = materialize_with_hint hint
time = Time.local **timespec, location: hint.location
rescue e : ArgumentError
raise ArgumentError.new "#{inspect} with hint #{hint} produced an invalid Time #{timespec} (#{e.message})"
end
max_tries = 100
tries = 0
Expand Down

0 comments on commit d5b7bcb

Please sign in to comment.