Skip to content

Instantly share code, notes, and snippets.

@ty-shaikh
Created November 30, 2019 18:14
Show Gist options
  • Save ty-shaikh/08631baac422d5347f55078457a570bd to your computer and use it in GitHub Desktop.
Save ty-shaikh/08631baac422d5347f55078457a570bd to your computer and use it in GitHub Desktop.
Calculate the days between when an item is posted and when the script is run.
def get_days(soup_obj):
"Convert to EST and return difference in days"
created_date = soup_obj['data-created-at']
pst_date = parse(created_date, ignoretz=True)
est_date = pst_date + timedelta(hours=3)
now = datetime.now()
diff = abs((est_date-now).days)
return diff
days = get_days(first_card)
print(days)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment