def closest(self, dt1, dt2):
        """
        Get the closest date from the instance.

        :type dt1: Date or date
        :type dt2: Date or date

        :rtype: Date
        """
        dt1 = self.__class__(dt1.year, dt1.month, dt1.day)
        dt2 = self.__class__(dt2.year, dt2.month, dt2.day)

        if self.diff(dt1).in_seconds() < self.diff(dt2).in_seconds():
            return dt1

        return dt2
def closest ( self , dt1 , dt2 ) : dt1 = self . __class__ ( dt1 . year , dt1 . month , dt1 . day ) dt2 = self . __class__ ( dt2 . year , dt2 . month , dt2 . day ) if self . diff ( dt1 ) . in_seconds ( ) < self . diff ( dt2 ) . in_seconds ( ) : return dt1 return dt2
Get the closest date from the instance.

        :type dt1: Date or date
        :type dt2: Date or date

        :rtype: Date