I need to get negative number after division by %
operator.
There is a new class that I created. It gets duration of process in milliseconds and represents it in seconds, minutes, hours and days.
In case of negative input, it should represent negative value of duration.
I made method for representing seconds.
class Duration:
def __init__(self, milliseconds: int):
self.__milliseconds = int(milliseconds)
def seconds(self):
return abs(self.__milliseconds) // 1000 % 60 * self.is_negative()
def is_negative(self):
return -1 if self.__milliseconds < 0 else 1
The function is_negative()
helps return negative value after %
division. Otherwise I get 1 after % divison, and it disrupts my add() calculation. Like Duration(1000)-Duration(3000)
or etc.
Is there more convinient way for getting seconds value in case of negative milliseconds value?