Phillip Pearson - web + electronics notes

tech notes and web hackery from a new zealander who was vaguely useful on the web back in 2002 (see: python community server, the blogging ecosystem, the new zealand coffee review, the internet topic exchange).

bzero 0.17 released

OK guys, [[bzero]] 0.17 is here. Get it from the usual place!

Lots of stuff has happened since 0.16; here’s the bit from the changelog:

* Added another troubleshooting note to the docs, and added python2.2-xmlbase to the list of Debian packages to install.

k-collector backend

A tip from Matt Mower (via email): the k-collector topic roll lets you get at all the topic information on the server.

(It also has info on an XML-RPC ping endpoint that I guess is the key to getting your blog included in the WWWW directory).

A quick hack on the Topic Exchange code lets it dump out its topic list in the same format. No idea how useful that is, but I guess another output format can’t hurt ;-)

Handling dates and times in Python

One of the tricks to programming effectively Python is knowing where all the date and time functions are. Every now and then I find another one that I didn’t know existed. Today I found that the email.Utils package has parsedate and formatdate methods that respectively parse and generate RFC-2822 dates to and from Python time tuples.

Previously I’d been using mxDateTime (which does everything but requires a C extension) to parse e-mail style dates (i.e. the ones used in RSS and changes.xml) but it looks like they’re handled by the standard library.

Here’s a quick summary of the date-handling functions I know about so far:

Unix timestamps and time tuples

time:

time - returns the time as a Unix timestamp

gmtime - turns a Unix timestamp into a time tuple w.r.t. GMT

localtime turns a Unix timestamp into a time tuple w.r.t. the local timezone

mktime - turns a time tuple w.r.t. the local timezone into a Unix timestamp

calendar:

timegm - turns a time tuple w.r.t. GMT into a Unix timestamp

Text formats

time:

asctime - turns a time tuple into some random text format

ctime - turns a Unix timestamp into a weird stringified time

email.Utils:

parsedate - turns an RFC-2822 date into a time tuple

formatdate - turns a time tuple into an RFC-2822 date

← Previous - Next →