to¶
- Time.to(target_unit: str, inplace: bool = False) Time
It converts actual
valueto a new value computed usingtarget_unitas the reference unit of measurement.If
inplaceisTrue, it overrides actualvalueandunit, otherwise it returns a new instance with the convertedvalueand thetarget_unitasunit.Parameters¶
Returns¶
TimeConverted time.
Raises
Examples
Timeinstantiation.>>> from gearpy.units import Time >>> t = Time(1, 'hour') >>> t ... 1 hour
Conversion from hour to second with
inplace = Falseby default, so it does not override the current value.>>> t.to('sec') ... 3600.0 sec >>> t ... 1 hour
Conversion from hour to second with
inplace = True, in order to override the current value.>>> t.to('sec', inplace = True) ... 3600.0 sec >>> t ... 3600.0 sec