Re: Small patch for more date information

Wari Wahab <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <1068027814.3409.20.camel@minisync>
I think nthday is ugly, no offence, I guess it could be done cleaner by
calculating what comes after a number instead.

Something like:

# Get the postfix of the number
th_day = {None:'th', 1:'st', 2:'nd', 3:'rd']
day_digit = int(self['da']) % 10
if th_day.has_key(day_digit): day_digit = None
self['daord'] = self['da'] + th_day[day_digit]

Of course, substitude the variables to a better named one :) I can't
seem to make any better ones.

On Sat, 2003-11-01 at 12:52, Patrick Wagstrom wrote:
> 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.
> 
> +        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['daord'] = nthday[int(self['da']) - 1][-2:]

> 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.




-------------------------------------------------------
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/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.