IMHO, the example's code is good, but not cool enough to be put in the
book. Every programmer saw those ordinary if...elif...elif...else
cliche in their first program language book before. People can
probably write their own if...elif...else in less time, than STFW or
RTFM to find our
the one in gluon tools does
prettydate(request.now,T)
On Feb 18, 7:49 am, Iceberg iceb...@21cn.com wrote:
IMHO, the example's code is good, but not cool enough to be put in the
book. Every programmer saw those ordinary if...elif...elif...else
cliche in their first program language book
added a few more cases:
def prettydate(d):
try:
dt = datetime.now() - d
except:
return ''
if dt.days = 2*365:
return '%d years ago' % int(dt.days / 365)
elif dt.days = 365:
return '1 year ago'
elif dt.days = 60:
return '%d months ago' %
for lack of a better option I put it in tools for now.
On Feb 15, 5:56 pm, Richard richar...@gmail.com wrote:
added a few more cases:
def prettydate(d):
try:
dt = datetime.now() - d
except:
return ''
if dt.days = 2*365:
return '%d years ago' %
These examples would be a very good edition to the book
--
J
On Mon, 2010-02-15 at 16:19 -0800, mdipierro wrote:
for lack of a better option I put it in tools for now.
On Feb 15, 5:56 pm, Richard richar...@gmail.com wrote:
added a few more cases:
def prettydate(d):
try:
Put this in a model
def prettydate(d):
try:
dt = request.now - d
except:
return ''
if dt.days=365*2:
return '%s years ago' % int(dt.days/365)
elif dt.days=365:
return '1 years ago'
elif dt.days=60:
return '%s months ago' %
:)
On Feb 15, 12:54 am, mdipierro mdipie...@cs.depaul.edu wrote:
Put this in a model
def prettydate(d):
try:
dt = request.now - d
except:
return ''
if dt.days=365*2:
return '%s years ago' % int(dt.days/365)
elif dt.days=365:
return '1
7 matches
Mail list logo