<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def moon_phase(self, date, rtype=int):
 """Calculates the phase of the moon on the specified date. :param date: The date to calculate the phase for. :type date: :class:`datetime.date` :param rtype: The type to return either int (default) or float. :return: A number designating the phase. | 0 = New moon | 7 = First quarter | 14 = Full moon | 21 = Last quarter """


        if rtype != float and rtype != int:
            rtype = int

        moon = self._moon_phase_asfloat(date)
        if moon >= 28.0:
            moon -= 28.0
        moon = rtype(moon)

        return moon