skip to navigation
skip to content

Not Logged In

py-pretty 1

Formats dates, numbers, etc. in a pretty, human readable format.

Sample code:

from datetime import datetime, timedelta
now = datetime.now()
hrago = now - timedelta(hours=1)
yesterday = now - timedelta(days=1)
tomorrow = now + timedelta(days=1)
dayafter = now + timedelta(days=2)

import pretty
print pretty.date(now)                      # 'now'
print pretty.date(hrago)                    # 'an hour ago'
print pretty.date(hrago, short=True)        # '1h ago'
print pretty.date(hrago, asdays=True)       # 'today'
print pretty.date(yesterday, short=True)    # 'yest'
print pretty.date(tomorrow)                 # 'tomorrow'
 
File Type Py Version Uploaded on Size
py-pretty-1.zip (md5) Source 2010-03-11 1KB
  • Downloads (All Versions):
  • 45 downloads in the last day
  • 415 downloads in the last week
  • 866 downloads in the last month