Actually commit the file

This commit is contained in:
Marco Pesenti Gritti 2007-02-13 15:54:24 +01:00
parent 64b92c4398
commit bf29a98b82

24
sugar/date.py Normal file
View File

@ -0,0 +1,24 @@
import datetime
class Date(object):
def __init__(self, timestamp):
self._timestamp = timestamp
def __str__(self):
date = datetime.date.fromtimestamp(self._timestamp)
today = datetime.date.today()
# FIXME localization
if date == today:
result = 'Today'
elif date == today - datetime.timedelta(1):
result = 'Yesterday'
elif date.year == today.year:
result = date.strftime('%B %d')
else:
result = date.strftime('%B %d, %Y')
time = datetime.datetime.fromtimestamp(self._timestamp)
result = result + ', ' + time.strftime('%I:%M %p')
return result