function Date:after(otherDate, noHour) return (self.year > otherDate.year or (self.year == otherDate.year and (self.month > otherDate.month or (self.month == otherDate.month and (self.day > otherDate.day or (self.day == otherDate.day and (not noHour and (self.hour > otherDate.hour or (self.hour == otherDate.hour and (self.minute > otherDate.minute or (self.minute == otherDate.minute and (self.second > otherDate.second)))))))))))) end
Refactorings
No refactoring yet !
Ants
December 7, 2009, December 07, 2009 20:56, permalink
I'm not fluent with LUA, but it seems to me that this can be simplified following this pseudo code:
selfDate = self
if noHour then
selfDate.hour = otherDate.hour
selfDate.minute = otherDate.minute
selfDate.second = otherDate.second
end
return os.difftime(os.time(selfDate), os.time(otherDate)) > 0
Check this in a cleaner way? (code written in LUA 4.0)