to¶
- TimeInterval.to(target_unit: str, inplace: bool = False) TimeInterval
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¶
TimeIntervalConverted time interval.
Raises
Examples
TimeIntervalinstantiation.>>> from gearpy.units import TimeInterval >>> dt = TimeInterval(1, 'hour') >>> dt 1 hour
Conversion from hour to second with
inplace=Falseby default, so it does not override the current value.>>> dt.to('sec') 3600.0 sec >>> dt 1 hour
Conversion from hour to second with
inplace=True, in order to override the current value.>>> dt.to('sec', inplace=True) 3600.0 sec >>> dt 3600.0 sec