Skip to content

Commit

Permalink
Add time unit conversion in FP_Quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
atuonufure committed Oct 4, 2023
1 parent d58e3f9 commit 848160f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fhirpathpy/engine/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ def conv_unit_to(fromUnit, value, toUnit):
if from_year_month_magnitude and to_year_month_magnitude:
return FP_Quantity(from_year_month_magnitude * value / to_year_month_magnitude, toUnit)

elif (
fromUnit in FP_Quantity._weeks_days_and_time
and toUnit in FP_Quantity._weeks_days_and_time
):
value_in_seconds = value * FP_Quantity.datetime_multipliers.get(fromUnit)
new_value = value_in_seconds / FP_Quantity.datetime_multipliers.get(toUnit)
return FP_Quantity(new_value, toUnit)

return None


Expand Down

0 comments on commit 848160f

Please sign in to comment.