Skip to content

Instantly share code, notes, and snippets.

View MohamedFaramawi's full-sized avatar

Mohamed Faramawi MohamedFaramawi

  • Egypt
  • 21:13 (UTC +03:00)
View GitHub Profile
@nzjrs
nzjrs / datedifference.py
Created October 11, 2009 11:38
Humanize date differences
#!/usr/bin/env python
# This function prints the difference between two python datetime objects
# in a more human readable form
#
# Adapted from: http://www.chimeric.de/blog/2008/0711_smart_dates_in_python
def humanize_date_difference(now, otherdate=None, offset=None):
if otherdate:
dt = otherdate - now
offset = dt.seconds + (dt.days * 60*60*24)