Skip to content

Commit

Permalink
Merge pull request #22 from savi-lang/update/latest-savi
Browse files Browse the repository at this point in the history
Update for breaking changes in Savi `v0.20230130.0`.
  • Loading branch information
jemc authored Jan 31, 2023
2 parents f8057ec + 67464b0 commit 600cdc0
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 163 deletions.
15 changes: 7 additions & 8 deletions src/Time.Duration.savi
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
)

:: Print the duration for human inspection (the format is subject to change).
:fun inspect_into(output String'iso)
:fun inspect_into(output String'ref) None
weeks_result = @total_weeks_with_remainder
days_result = weeks_result.tail.total_days_with_remainder
hours_result = days_result.tail.total_hours_with_remainder
Expand All @@ -183,42 +183,41 @@
output << "Time.Duration("

if (weeks > 0) (
output = Inspect.into(--output, weeks), output << " weeks"
Inspect.into(output, weeks), output << " weeks"
printed_anything = True
)

if (days > 0) (
if printed_anything (output << ", ")
output = Inspect.into(--output, days), output << " days"
Inspect.into(output, days), output << " days"
printed_anything = True
)

if (hours > 0) (
if printed_anything (output << ", ")
output = Inspect.into(--output, hours), output << " hours"
Inspect.into(output, hours), output << " hours"
printed_anything = True
)

if (minutes > 0) (
if printed_anything (output << ", ")
output = Inspect.into(--output, minutes), output << " minutes"
Inspect.into(output, minutes), output << " minutes"
printed_anything = True
)

if (seconds > 0) (
if printed_anything (output << ", ")
output = Inspect.into(--output, seconds), output << " seconds"
Inspect.into(output, seconds), output << " seconds"
printed_anything = True
)

if (nanoseconds > 0) (
if printed_anything (output << ", ")
output = Inspect.into(--output, nanoseconds), output << " nanoseconds"
Inspect.into(output, nanoseconds), output << " nanoseconds"
printed_anything = True
)

output << ")"
--output

:: Return True if the given duration is exactly equivalent to this one.
:fun "=="(other Time.Duration'box)
Expand Down
Loading

0 comments on commit 600cdc0

Please sign in to comment.