ago

Human readable timedeltas
Download

ago Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Public Domain
  • Price:
  • FREE
  • Publisher Name:
  • Russell Ballestrini
  • Publisher web site:
  • https://bitbucket.org/russellballestrini/

ago Tags


ago Description

ago is a Python module that provides human readable timedeltas.How to installeasy_install agoHow to useImport ago and create a timedelta object:from ago import delta2dict, humanfrom datetime import datetime# pretend this was stored in databased1 = datetime( year = 2010, month=5, day=4, hour=6, minute=54, second=33, microsecond=4000 )# this is right nowd2 = datetime.now()# subtract the two for a timedelta objectdelta = d2 - d1# create a dictionary out of the timedelta# not needed but accessabledelta_dict = delta2dict( delta )print delta_dict# display a human readable timedeltaprint 'Created ' + human( delta ) + ' ago.'# optionally pass a precisionprint 'Created ' + human( delta, 3 ) + ' ago.'print 'Created ' + human( delta, 6 ) + ' ago.'Product's homepage


ago Related Software