Index: src/OFDate.h ================================================================== --- src/OFDate.h +++ src/OFDate.h @@ -287,17 +287,21 @@ - (OFString*)localDateStringWithFormat: (OFConstantString*)format; /*! * @brief Returns the earlier of the two dates. * + * If the argument is nil, it returns the receiver. + * * @param otherDate Another date * @return The earlier date of the two dates */ - (OFDate*)earlierDate: (OFDate*)otherDate; /*! * @brief Returns the later of the two dates. + * + * If the argument is nil, it returns the receiver. * * @param otherDate Another date * @return The later date of the two dates */ - (OFDate*)laterDate: (OFDate*)otherDate; Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -605,18 +605,24 @@ return ret; } - (OFDate*)earlierDate: (OFDate*)otherDate { + if (otherDate == nil) + return [[self retain] autorelease]; + if ([self compare: otherDate] == OF_ORDERED_DESCENDING) return [[otherDate retain] autorelease]; return [[self retain] autorelease]; } - (OFDate*)laterDate: (OFDate*)otherDate { + if (otherDate == nil) + return [[self retain] autorelease]; + if ([self compare: otherDate] == OF_ORDERED_ASCENDING) return [[otherDate retain] autorelease]; return [[self retain] autorelease]; }