Small patch for more date information
Patrick Wagstrom <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I made a small patch to pyblosxom to allow for more full date
information for the entires. Namely, I wanted to get the full month
name and the ordinal for the day. It's my belief that this lies more in
the base than in a plugin, so I put it there.
--- /home/patrick/src/pyblosxom-0.8.1/Pyblosxom/entries/base.py Fri Jun 6 08:10:06 2003
+++ /home/patrick/Documents/www/pyblosxom/Pyblosxom/entries/base.py Fri Oct 31 23:39:36 2003
@@ -175,14 +175,20 @@
is the same thing as the mtime/atime portions of an os.stat.
@type timeTuple: tuple of ints
"""
+ nthday = ["", "1st", "2nd", "3rd", "4th", "5th", "6th" "7th", "8th", "9th", "10th",
+ "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th",
+ "21st", "22nd", "23rd", "24th", "25th", "26th", "27th", "28th", "29th", "30th",
+ "31st"]
self['timetuple'] = timeTuple
self._mtime = time.mktime(timeTuple)
gmTimeTuple = time.gmtime(self._mtime)
self['mtime'] = self._mtime
self['ti'] = time.strftime('%H:%M', timeTuple)
self['mo'] = time.strftime('%b', timeTuple)
+ self['month'] = time.strftime('%B', timeTuple)
self['mo_num'] = time.strftime('%m', timeTuple)
self['da'] = time.strftime('%d', timeTuple)
+ self['daord'] = nthday[int(self['da']) - 1][-2:]
self['dw'] = time.strftime('%A', timeTuple)
self['yr'] = time.strftime('%Y', timeTuple)
self['fulltime'] = time.strftime('%Y%m%d%H%M%S', timeTuple)
Basically, this provides two new variables for use, $month and $daord.
$month is the full month name and $daord is the ordinal of the day (st,
dn, rd, th). Mainly I wanted them to make the reported days look a
little nicer. This doesn't change any of the URL stuff. Anyone know of
a better way to do the ordinal stuff? Perl has a nice %o modifier, that
python doesn't seem to have.
--Patrick
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/