PyFunceble/execution_time.py
def _calculate(cls, start=None, end=None):
        """
        calculate the difference between starting and ending time.

        :param start: A starting time.
        :type start: int|str

        :param stop: A ending time.
        :type stop: int|str

        :return:
            A dict with following as index.

                * :code:`days`
                * :code:`hours`
                * :code:`minutes`
                * :code:`seconds`

            as index.
        :rtype: dict
        """

        if start and end:
            # The start and end time is explicitly given.

            # We get the difference between the ending and the starting time.
            time_difference = int(end) - int(start)
        else:
            # The start and end time is not explicitly given.

            # We get the difference between the ending and the starting time.
            time_difference = PyFunceble.INTERN["end"] - PyFunceble.INTERN["start"]

        # We initiate an OrderedDict.
        # Indeed, we use an ordered dict because we want the structuration and the
        # order to stay always the same.
        # As a dictionnary is always unordered, we can use it. Otherwise the time will
        # not be shown correctly.
        data = PyFunceble.OrderedDict()

        # We calculate and append the day to our data.
        data["days"] = str(time_difference // (24 * 60 * 60)).zfill(2)

        # We calculate and append the hours to our data.
        data["hours"] = str((time_difference // (60 * 60)) % 24).zfill(2)

        # We calculate and append the minutes to our data.
        data["minutes"] = str((time_difference % 3600) // 60).zfill(2)

        # We calculate and append the minutes to our data.
        data["seconds"] = str(time_difference % 60).zfill(2)

        # We finaly return our data.
        return data
def _calculate(cls, start=None, end=None):
        if start and end:
            # The start and end time is explicitly given.

            # We get the difference between the ending and the starting time.
            time_difference = int(end) - int(start)
        else:
            # The start and end time is not explicitly given.

            # We get the difference between the ending and the starting time.
            time_difference = PyFunceble.INTERN["end"] - PyFunceble.INTERN["start"]

        # We initiate an OrderedDict.
        # Indeed, we use an ordered dict because we want the structuration and the
        # order to stay always the same.
        # As a dictionnary is always unordered, we can use it. Otherwise the time will
        # not be shown correctly.
        data = PyFunceble.OrderedDict()

        # We calculate and append the day to our data.
        data["days"] = str(time_difference // (24 * 60 * 60)).zfill(2)

        # We calculate and append the hours to our data.
        data["hours"] = str((time_difference // (60 * 60)) % 24).zfill(2)

        # We calculate and append the minutes to our data.
        data["minutes"] = str((time_difference % 3600) // 60).zfill(2)

        # We calculate and append the minutes to our data.
        data["seconds"] = str(time_difference % 60).zfill(2)

        # We finaly return our data.
        return data
def _calculate ( cls , start = None , end = None ) : if start and end : # The start and end time is explicitly given. # We get the difference between the ending and the starting time. time_difference = int ( end ) - int ( start ) else : # The start and end time is not explicitly given. # We get the difference between the ending and the starting time. time_difference = PyFunceble . INTERN [ "end" ] - PyFunceble . INTERN [ "start" ] # We initiate an OrderedDict. # Indeed, we use an ordered dict because we want the structuration and the # order to stay always the same. # As a dictionnary is always unordered, we can use it. Otherwise the time will # not be shown correctly. data = PyFunceble . OrderedDict ( ) # We calculate and append the day to our data. data [ "days" ] = str ( time_difference // ( 24 * 60 * 60 ) ) . zfill ( 2 ) # We calculate and append the hours to our data. data [ "hours" ] = str ( ( time_difference // ( 60 * 60 ) ) % 24 ) . zfill ( 2 ) # We calculate and append the minutes to our data. data [ "minutes" ] = str ( ( time_difference % 3600 ) // 60 ) . zfill ( 2 ) # We calculate and append the minutes to our data. data [ "seconds" ] = str ( time_difference % 60 ) . zfill ( 2 ) # We finaly return our data. return data
calculate the difference between starting and ending time.

        :param start: A starting time.
        :type start: int|str

        :param stop: A ending time.
        :type stop: int|str

        :return:
            A dict with following as index.

                * :code:`days`
                * :code:`hours`
                * :code:`minutes`
                * :code:`seconds`

            as index.
        :rtype: dict
calculate the difference between starting and ending time .