Exemple #1
0
    def compareDateTime(self, comp):
        if comp is None:
            return 1
        # If either are date only, then just do date compare
        if self.mDateOnly or comp.mDateOnly:
            c = cmp(self.mYear, comp.mYear)
            if c == 0:
                c = cmp(self.mMonth, comp.mMonth)
                if c == 0:
                    c = cmp(self.mDay, comp.mDay)
            return c

        # If they have the same timezone do simple compare - no posix calc
        # needed
        elif (Timezone.same(self.mTZUTC, self.mTZID, comp.mTZUTC, comp.mTZID)):
            c = cmp(self.mYear, comp.mYear)
            if c == 0:
                c = cmp(self.mMonth, comp.mMonth)
                if c == 0:
                    c = cmp(self.mDay, comp.mDay)
                    if c == 0:
                        c = cmp(self.mHours, comp.mHours)
                        if c == 0:
                            c = cmp(self.mMinutes, comp.mMinutes)
                            if c == 0:
                                c = cmp(self.mSeconds, comp.mSeconds)
            return c

        else:
            return cmp(self.getPosixTime(), comp.getPosixTime())
Exemple #2
0
    def compareDateTime(self, comp):
        if comp is None:
            return 1
        # If either are date only, then just do date compare
        if self.mDateOnly or comp.mDateOnly:
            c = cmp(self.mYear, comp.mYear)
            if c == 0:
                c = cmp(self.mMonth, comp.mMonth)
                if c == 0:
                    c = cmp(self.mDay, comp.mDay)
            return c

        # If they have the same timezone do simple compare - no posix calc
        # needed
        elif (Timezone.same(self.mTZUTC, self.mTZID, comp.mTZUTC, comp.mTZID)):
            c = cmp(self.mYear, comp.mYear)
            if c == 0:
                c = cmp(self.mMonth, comp.mMonth)
                if c == 0:
                    c = cmp(self.mDay, comp.mDay)
                    if c == 0:
                        c = cmp(self.mHours, comp.mHours)
                        if c == 0:
                            c = cmp(self.mMinutes, comp.mMinutes)
                            if c == 0:
                                c = cmp(self.mSeconds, comp.mSeconds)
            return c

        else:
            return cmp(self.getPosixTime(), comp.getPosixTime())
    def compareDateTime(self, comp):
        if comp is None:
            return 1
        # If either are date only, then just do date compare
        if self.mDateOnly or comp.mDateOnly:
            if self.mYear == comp.mYear:
                if self.mMonth == comp.mMonth:
                    if self.mDay == comp.mDay:
                        return 0
                    else:
                        if self.mDay < comp.mDay:
                            return -1
                        else:
                            return 1
                else:
                    if self.mMonth < comp.mMonth:
                        return -1
                    else:
                        return 1
            else:
                if self.mYear < comp.mYear:
                    return -1
                else:
                    return 1

        # If they have the same timezone do simple compare - no posix calc
        # needed
        elif (Timezone.same(self.mTZUTC, self.mTZID, comp.mTZUTC, comp.mTZID)):
            if self.mYear == comp.mYear:
                if self.mMonth == comp.mMonth:
                    if self.mDay == comp.mDay:
                        if self.mHours == comp.mHours:
                            if self.mMinutes == comp.mMinutes:
                                if self.mSeconds == comp.mSeconds:
                                    return 0
                                else:
                                    if self.mSeconds < comp.mSeconds:
                                        return -1
                                    else:
                                        return 1
                            else:
                                if self.mMinutes < comp.mMinutes:
                                    return -1
                                else:
                                    return 1
                        else:
                            if self.mHours < comp.mHours:
                                return -1
                            else:
                                return 1
                    else:
                        if self.mDay < comp.mDay:
                            return -1
                        else:
                            return 1
                else:
                    if self.mMonth < comp.mMonth:
                        return -1
                    else:
                        return 1
            else:
                if self.mYear < comp.mYear:
                    return -1
                else:
                    return 1
        else:
            posix1 = self.getPosixTime()
            posix2 = comp.getPosixTime()
            if posix1 == posix2:
                return 0
            else:
                if posix1 < posix2:
                    return -1
                else:
                    return 1