# Quiet Evening

There's not much to say about Labour Day at all as far as I'm concerned, save that it was another opportunity for resting, reading, puttering about the house and doing some casual surfing:

• The much-hyped ABC Full Episode Streaming page is (predictably) blocked to European users. US-based proxies would be welcome if I didn't plan to get the shows on DVD later and watch them as I please (i.e., without ads at all, on whatever device I feel like using).
• I stay away from Politics as much as I possibly can (and then some), but there was no way I was going to miss out on Stephen Colbert's amazing address (video, transcript).
• I found out about AutoViewer, another very nice (if bandwidth-intensive) image viewer that can superimpose captions on images (haven't tested accented characters, but apparently some are not included in the embedded Flash font). See more in my Flash/Snippets node.
• I've been tinkering with Textpander (via Hawk Wings). Don't think I'll be using it for much, but it's interesting.

And since I haven't posted any code in a while, here's a first stab at human-readable time strings in Python - this outputs the usual posted 2 years, 1 month ago stuff, enhanced to have an arbitrary time range and detail - for instance, you can specify 3 levels of detail and get 3 days, 2 hours, 14 minutes ago:

def timeSince(older=None,newer=None,detail=2):
"""
Human-readable time strings, based on Natalie Downe's code from
http://blog.natbat.co.uk/archive/2003/Jun/14/time_since
Assumes time parameters are in seconds
"""
intervals = {
60 * 60 * 24 * 365: 'year',
60 * 60 * 24 * 30: 'month',
60 * 60 * 24 * 7: 'week',
60 * 60 * 24: 'day',
60 * 60: 'hour',
60: 'minute',
}
chunks = intervals.keys()
# Reverse sort using a lambda (for Python 2.3 backwards compatibility)
chunks.sort(lambda x, y: y-x)
if interval < 0:
raise ValueError('Time interval cannot be negative')
output = ''
for steps in range(detail):
for seconds in chunks:
count = math.floor(interval/seconds)
unit = intervals[seconds]
if count != 0:
break
if count > 1:
unit = unit + 's'
if count != 0:
output = output + "%d %s, " % (count, unit)
interval = interval - (count * seconds)
output = output[:-2]
return output

And yes, I can do the sorting and other subtleties in other ways, but I'm still stuck in Tiger's bundled Python 2.3 and want to make sure this runs there.