def datetime_format(dtobj):
 (year, month, day) = (dtobj.year, dtobj.month, dtobj.day)
 (hour, minute, second) = (dtobj.hour, dtobj.minute, dtobj.second)
 now = timezone.now()
 if (year < now.year):
  timestring = str(dtobj.date())
 elif (dtobj.date() < now.date()):
  timestring = ('%02i-%02i' % (day, month))
 elif (hour < (now.hour - 1)):
  timestring = ('%02i:%02i' % (hour, minute))
 else:
  timestring = ('%02i:%02i:%02i' % (hour, minute, second))
 return timestring

def datetime_format ( dtobj ) : ( year , month , day ) = ( dtobj . year , dtobj . month , dtobj . day ) ( hour , minute , second ) = ( dtobj . hour , dtobj . minute , dtobj . second ) now = timezone . now ( ) if ( year < now . year ) : timestring = str ( dtobj . date ( ) ) elif ( dtobj . date ( ) < now . date ( ) ) : timestring = ( '%02i-%02i' % ( day , month ) ) elif ( hour < ( now . hour - 1 ) ) : timestring = ( '%02i:%02i' % ( hour , minute ) ) else : timestring = ( '%02i:%02i:%02i' % ( hour , minute , second ) ) return timestring
pretty-prints the time since a given time .